Login

What is Google Tag Manager? Part Two

Written by 4 minute read

The new version of google tag manager, released back in October 2014 saw a brand new UI, a lot of functionalities plus new terminology to cope with.

The new version has moved away from the programming-centric concepts of Macros and Rules to the more tactile variables and Triggers.

One of the Awin tags asks me for order refs, price what’s all that about?

Good question, glad you’re trying the awin tags… Time to call in Variables
Variables are like little container boxes that you can use to store almost anything. This is a significant achievement in efficiency, because it means that values can be reused across functions, procedures, and environments. In this case it would be values from your site (order Ref, sale amount etc.), you can have static values and in GTM they’re declared as constants (watch out these never change) or dynamic ones which can constantly change.

In Google Tag Manager, the term Variable is used to denote a helper function that the Tags, Triggers, and other Variables can invoke to retrieve values from. This idea is very similar to the broader concept of computing variables.

In GTM, invoking the Variable function is done with a specific syntax:

{{Variable name}}

You can’t invoke variables wherever or anywhere you’d want to. But in an approved context, the syntax {{variable name}} would run the underlying function of the Variable with the name “variable name”, and pass the value returned by that function to its execution context (the Tag, Trigger, or Variable where the syntax was used).

Variable types:

tablet

There are a number of useful Variable types for you to choose from, and you can use the Custom JavaScript Variable to create custom Variables of your own. Many of the Variable types have some cool customization options as well, so you should take the time to study their many uses.

Built-in Variables

The new version of Google Tag Manager introduced Built-in Variables. These are helpful, most commonly used Variables, and their existence is based on binary logic: active / inactive. If the Built-in Variable is activated, it can be used as any other Variable, and if it’s not activated, it can’t. You will find the Built-in Variables displayed prominently in the top of the Variables screen of your Google Tag Manager Container:

tablet

If the box next to a Built-in Variable is checked, it is active and can be used, and if it isn’t checked, the Variable is inactive.

As with all Variables, if the Built-in Variable cannot be resolved (e.g. there was no Click action and you want to use Click ID), the Variable returns the JavaScript undefined type.

For more information on variables please check here.

For you to be able to invoke a GTM Variable, you need to be working in a script context, or the template field needs to support Variable references.

tablet

As you can see, the “Tag Name” field will not be able to invoke a Variable, but the “Tracking ID” will. In fact, if you click the little Variable icon, you will see a drop-down list from which you can pick the Variable you want to use. This way you don’t have to worry about correct syntax, as GTM will do it for you.

tablet

The other places you’d use variables are: Triggers, customs HTML Tags and custom JavaScript variables.

What’s a datalayer variable?

A data layer is an object that contains all of the information that you want to pass to Google Tag Manager. Information such as events or variables can be passed to Google Tag Manager via the data layer, and triggers can be set up in Google Tag Manager based on the values of variables (e.g., fire a remarketing tag when OrderRef > 1) or based on the specific events.

 Check more on data layer here.

What about triggers?

In the new version of Google Tag Manager, one of the most visible and profound changes to the previous version is how tags are fired (and blocked). First of all, there’s the obvious terminological distinction: we talk about triggers now, not rules. Second, triggers have become an integral part of the tag creation workflow, and as such have far more significance in the user interface than before.

tablet

We will be covering more on the changes and technical overview on triggers and conditions on the next edition…