Digital

6 Must Have Google Tag Manager Variables

The power of GTM lies in its potential for transformation. Yes, you read that correctly! It has the ability to turn a rigid organization into something more agile, with more communication and more efficiency. But beware! I'm not telling you that I'm going to fix your company, but it will provide you with the tools to start improving your work processes.

For this reason, today I want to help you delve a little deeper into the world that is Google Tag Manager and I will present some variables that will help get you out of more than one jam you’re facing in your web project.

Google Analytics Configuration

With this variable we can configure all the Google Analytics parameters that we need and reuse them in all our GA tags.

It is recommended to keep a configuration variable that saves, at least the UA identifier of our main property. We can complete it with some values like the activation of the tab of the display advertising function.

Not only does it save us work, but it also allows to have greater collaboration and work sharing options, by facilitating the possibility of separating tasks (internal configuration management of Analytics vs tag parameters) between different users or agencies.

  • Create a new type of variable: Google Analytics Settings

  • Specify the usual GA options that we want (as a minimum, property ID and domain of the cookie, usually leaving the automatic value "auto") and save.

Get the anchor or hash (#) fragment of a URL

It is common to use the hash delimiter (#) in URLs as anchors to different parts of a page. Especially in web apps that show all the content on a single screen. By default, the analytics tools do not consider the content of the URLs that goes after the #, but with this variable we can modify this behavior by default.

The configuration is very simple: we select a variable of type << URL >> and in the drop-down of << Component Type >> we select << Fragment >> In this way we capture the fragment of the URL that has loaded in the variable.

By default the variable will return the hash of the URL of the page on which our visitor is located. If we want to work with the URL that has been clicked, in << More Settings >> we will find a drop-down where to select the variable {{Click URL}}

Using this variable we can capture any other option of the URL, such as the protocol, which can also be useful in other types of implementations.

Title of a page

With this variable we can recover the title of a page (HTML title tag) It is a very common variable in any project and it is also very simple to define.

To do this we are going to create a variable of the type << JavaScript Variable >> and in the field << Global Variable Name >> we write: document.title

Something as simple as this allows us to recover the title of each page. We can access any other variable in the document in an analogous way.

Convert a string to lowercase / uppercase

Many of the tools are case-sensitive. That is why it can be useful to pass the strings to lowercase in order to unify the information. To do this, we create a variable of the type << Custom Javascript  >> and give it a descriptive name. In the following example what we reduce is the variable {{Click Text}} so we could call it Click Text Lower Case.

We can change the variable {{Click Text}} by any other variable that we want to pass to lowercase.

Remove spaces

This variable allows us to transform another by replacing any character with another. It can be used to delete spaces or change them for any other character such as a hyphen (-)

This example serves to replace the spaces with hyphens in the variable {{Click Text}}, but once again we can use it with the variable that we want and make the substitution that interests us the most.

Access to the revenue of the Enhanced Ecommerce 

The implementation of Enhanced Ecommerce  requires the insertion of all the information related to the transaction of a Data Layer. To access any of the values ​​stored in the data layer we can do it using a variable of type << Data Layer Variable >>

This example is to retrieve the total value of the transaction when a sale has occurred, and you can use it in any conversion tag that needs it. In the Data Layer Variable name we write:

ecommerce.purchase.actionField.revenue

Google Tag Manager may seem at first sight an impossible beast to tame but you will only need to spend a little time to realize everything it can do for you.

From BeDjango we would like to invite you to join this legion of people who already use Google Tag Manager and to prepare yourself to witness their capacity for transformation.

About the author

Digital Marketing enthusiast - telling stories behind data

Let’s have a coffee and talk about your project

START A PROJECT

Let’s have a coffee and talk about your project

START A PROJECT

We use cookies to ensure you get the best experience on our website. More info.

Accept