A Guide to Google Tag Manager Variables

Google Tag Manager Variables

This is an intermediate article on Google Tag Manager. If you’re new to GTM, we recommend you read our two previous posts on the topic.

  1. How to Install Google Tag Manager
  2. Google Tag Manager Tutorial for Beginners

Introduction to Google Tag Manager Variables

If you have ever wondered how to track dynamic conversion values to accurately measure your campaigns results, variables are your answer.

Google Tag Manager variables are one of the most important components in this tool and, armed with the proper knowledge of how they work, will take your reporting to a whole different level.

Whether you need to pull dynamic conversion values, or track very specific user actions such as button clicks, form fills, or other types of events, you will learn the basics on how to do so in this post.

Let’s get to it.

What Are Google Tag Manager Variables?

Variables are “(…) named placeholders for values that are populated when code is run on your website or mobile app.”, according to Google.

In other words, variables hold values for different elements on your website.

For example, the “Page URL” variable on this page contains the value “theconversionlift.com/tag-manager-tags-variables”.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2fe60446-6941-4645-854a-6ebaff23063e/Untitled.png

How to Create Variables in Google Tag Manager

There are two different types of variables you can use in Googe Tag Manager.

  • Buit-In Variables: these are pre-created by Google, and non-customizable. You can use them in a wide array of different scenarios.
  • User-Defined Variables: custom user-defined variables that can be used to cover specific requirements not already covered by built-in variables.

Built-In Variables

Before you can use built-in variables, you’ll need to enable them first.

To do so, access the variables pannel in Google Tag Manager by clicking on the “Variables” button in the left sidebar panel.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/349cae10-cc27-4c3c-8b75-1ae76feacea8/Untitled.png

Click on the “configure” button in the top-right and check the tick-boxes for the variables you wish to enable.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a99e702c-cc1b-4fa4-b08c-73507388f08e/Untitled.png

Once you enable these variables, they will become visible when you enable Google Tag Manager’s preview mode – and you can use them in your tags, and triggers.

We’ll cover more of the preview tool in a minute.

User-Defined Variables

In some cases, you’ll need variables that aren’t covered by the default pre-selection that comes with Google Tag Manager.

To create user-defined variables, scroll down to the bottom of the page and, in the user-defined variables section, click on the “new” button.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/03d0ba1c-ed54-41ce-a6f8-7c666e21ab3a/Untitled.png

There are lots of different user-defined variable types you can choose from, and an almost endless amount of variables you can create.

We won’t cover the different variables in this post, but we’ll show you some examples in a few minutes.

In case you’re curious, here’s a list of the variable types you can create.

How To Identify Variables On Your Website

To make all this easier to understand, let’s take a look at Google Tag Manager’s preview tool. To enable the preview mode, click on the “Preview” button on the top of your dashboard.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/201b5926-e0eb-4b06-b860-93c188c08779/Untitled.png

Once enabled, open your website on a different browser. You should see the preview mode panel in the bottom of your screen.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2fe60446-6941-4645-854a-6ebaff23063e/Untitled.png

After clicking one of the events on the summary column to the left, and then on the variables button on the header of the panel, you will see a list with all the available variables, and their respective values.

For example, in the image above, the variable “Page Path” contains the value “/analytics-tools/google-tag-manager-tutorial”.

You can use these variables and their respective values to trigger tags, pull values into tags, or even create new variables.

How To Use Google Tag Manager Variables

As we discussed, variables can be used in both triggers, and tags. They serve different purposes, but are fundamental in both cases.

  • In Tags: used to capture dynamic values;
  • In Triggers: used to define filters that specify when a particular tag should fire.

Let’s look at an example to make that easier to understand.

Variables In Tags

Let’s assume you own an eCommerce store that sells men’s clothing for customers in Europe.

In an effort to increase sales on your store, you’ve launched a Google Ads campaign and want to add different Google Ads conversion tags to measure how many users add products to cart, checkout, and purchase, and the respective values for each event.

To do that, you would have to follow a few easy steps.

  1. Use the preview mode to identify the variable that contains the product’s price.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d0c1a9e7-afb7-4759-a77f-39eeed7c8156/Untitled.png
  1. Create a Google Ads conversion tag that fires whenever a user adds a product to the cart.
  1. Add the “dlv – price” tag in the “value” field, in curly brackets, to pull the variable’s value into the tag.
https://s3-us-west-2.amazonaws.com/secure.notion-static.com/1c390f28-a0fe-4747-9d9c-fae8f1fa1fa0/Untitled.png

Before you can save and publish the tag, you’ll need to add a trigger that fires whenever someone adds a product to the cart.

You can do this in a few simple steps.

Variables In Triggers

As we mentioned, variables can also be used to define new trigger conditions.

In the case above, you’ll need to identify a variable that “tells you” whenever someone adds a product to cart.

Taking a look at the preview tool again, when we click the “Add to Cart” button, we can see that the built-in “Click Text” variable contains an “ADD TO CART” value.

We’ll use this to create our trigger.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a68d78ad-62a8-47cd-8985-7e65904e66bd/Untitled.png

When you create a click-based trigger, you’ll use the value above to define when it should fire.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ccb359fd-23da-4469-985c-52ad8374f108/Untitled.png

In the preview mode in the image above, you can see an “addToCart” event under the summary column, to the left. We’ll explain how to push custom events with the data layer in another post.

You can then add the trigger to your tag, and hit the publish button.

What’s Next?

Google Tag Manager variables are essential to accurate reporting.

Now that you’ve learned how to use some of the more basic variables, it’s time you move on to a more advanced level of Google Tag Manager.

The next article in this series will cover the basics of the Data Layer – and will teach you how to pull almost any data element from your website, and turn them into variables you can use in your tags and triggers.

In fact, in this post, we have already created a data layer variable: the “dlv – price” variable. We used this variable to pull the price from the product added to the cart, and include it in our reports.

So how exactly can we do that?


Did you have any trouble setting up your first variables?

If so, let us know in the comments and let’s talk!

Make sure you subscribe to our newsletter to be the first to receive next week’s post, directly in your inbox.

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Terms and Conditions and the Privacy Policy

You May Also Like