You are here: Tags / custom javascript
One of Google Tag Manager’s oldest and most reliable features is that it freezes the state of Data Layer variables to the moment when the trigger event occurred. Thus, any tags firing on this trigger (and any variables resolved on this trigger event) will always have access to the same value of each Data Layer variable. However, there are situations where this is not a good thing. One is tag sequencing, and the other is a scenario where you want to run some custom code that should access the latest value of the Data Layer variable at a moment in time after the tag has already fired.

Continue reading

In Google Tag Manager, the Custom JavaScript variable is an anonymous function with a return statement. It does not take any parameters, and by default it’s impossible to pass any parameters to it, because the Custom JS variable is simply resolved to whatever value the function returns. If it returns a number, for example, passing a parameter to it would make no sense and would result in a TypeError since the variable resolves to a number, not a function.

Continue reading

Google Tag Manager provides us with a bunch of handy triggers, designed to make capturing user interactions on the website much easier. These triggers are part of a paradigm called auto-event tracking, which comprises the Click, Form, History, and JavaScript Error trigger types. Now, I’ve covered GTM’s triggers many, many times before. If you need a refresher, take a look at the following articles: Trigger Guide For Google Tag Manager Auto-Event Tracking In GTM 2.

Continue reading

Author's picture

Simo Ahava

Husband | Father | Analytics developer
simo (at)

Senior Data Advocate at Reaktor