Comprehensive Guide on GTM Tags

As the owner of a website or mobile app, one of your key objectives is probably to increase the traffic flow to your site. This is only possible if you can track the existing traffic accurately and use certain methods or tools to optimize your marketing efforts. And, options like Google Analytics, Firebase Analytics, and Google Adwords are perfectly suited for traffic analysis and marketing optimization. These tools use tags (code snippets) that have to be included in the source code of your website or app.

For example, the Google Analytics tag added to your website’s source code will send information or details about the traffic and related activity on your site back to Google Analytics. But, you need the developers to configure Google Analytics tags. Hence, it is better to use a tag management system, such as Google Tag Manager (GTM), which empowers you to update third-party or custom tags from its user interface itself, without any site code modification.

So, in this article, we take a closer look at these GTM tags, their purpose, and their usage.

GTM Tags Overview

In terms of digital marketing and analytics, tags are blocks of code that enable activity information from your website or app to be passed on to third-party providers, such as Google Analytics.  But, with GTM, you can avoid inserting any such tracking code snippets into your site’s source files and, instead, just specify the tags that need to be triggered and when you want them to be triggered. This is possible through the GTM web user interface that provides you control over all the tags.

Some of the key benefits of GTM tags are:

  • Simplifying the publishing of tracking codes
  • Adding or updating tags for Google Adwords, Floodlight, Firebase Analytics, Google Analytics, and similar third-party tags or custom tags from the GTM user interface
  • Avoiding editing the source code files
  • Reducing errors
  • Removing the dependency on developers for tag configuration

How to Use Tags in GTM?

You can either deploy a tag by using built-in templates present in GTM or by using custom tags. In general, you can consider a tag as a piece of code that is executed on any of your website’s pages.

For the web, GTM operates by using its own container tag (replacing any of the other manually coded tags) which is placed on all the pages of your website. For mobile apps, GTM works with the container tag in conjunction with Firebase SDK through support for iOS and Android platforms. A default container is used for the initial tag configurations only, until a container is downloaded for the first time on mobile for apps. After the GTM container tag is added to your website or app, you can easily update or add tags from the Tag Manager web interface.

So, GTM offers you templates for Google tags, such as Adwords and Analytics, and for several other certified vendors. You can check out a list of supported tags here. comprehensive_guide_1To use any template, just select it and enter the necessary details. You then have to specify certain “triggers” that will make GTM automatically generate the corresponding code and fire the tag. The tags fire or execute when there is any response to an interaction or activity on your page or even when the page loads. The “triggers” help to specify when the tags should fire. For example, “All pages” is a predefined trigger that makes your tag fire whenever any page on your website is loaded.

We will dive deeper into triggers and the associated variables during the later part of this article.

Steps to Set up GTM Tags for the Web

  • Go to GTM and access your existing account or create a new one.comprehensive_guide_2
  • Create a container for your website through your GTM account.
  • Once the container is created, you need to add the generated code snippet to your website.
  • Before you fire any of the tags from GTM, migrate any of the hard-coded tags from your website’s source code files to the Tag Manager, though you may not be obligated to migrate all the hard-coded tags.

Steps to Set up GTM Tags for Mobile Apps

  • Navigate to the GTM website and access your existing account or create a new one.
  • Create a container for your app using the “mobile app” option in your GTM account.
  • Choose the appropriate SDK version (Firebase or legacy SDKs) and container type (iOS or Android). This is required because GTM for mobile apps is integrated with Google’s mobile app platform (Firebase).

Once the above setup steps have been completed, you can manage all the future tags for your website or mobile app by using the GTM interface. Your GTM account gives you the administrative capability for tags belonging to single or multiple websites or apps. This saves you from the hassle of creating multiple Tag Manager accounts.

Steps to Set up Firing Tags

How does GTM fire tags? Well, it uses triggers, variables, and a data layer to set up the firing of tags on mobile apps or the web.comprehensive_guide_3For the GTM “trigger”, you provide a condition that can either be true or false at runtime by comparing its value to the value in a “variable” which is populated during runtime. GTM consists of different built-in variables and even allows you to set up custom variables.

For example, the built-in variable “url” contains the URL of the web page currently loaded. However, if you intend to only fire a tag on a particular web page, then you need to have the relevant trigger defined with the condition that the URL contains the link of that specific web page.

You can define the variables to contain certain values (say the transaction amount) at runtime and this will be used as the basis on which triggers will be initiated. Now, these values at runtime will be dynamic and need to be fetched using the “data layer” object from your website’s source code (the values have to be pushed to the data layer). Thus, the data layer object contains the information you intend to pass to GTM and the data layer variables enable the capturing of these values for later use.

Though it is not mandatory to configure a data layer object from which your variables can retrieve runtime information, it is definitely a best practice so that you do not have to depend on those values being fetched from DOM, JavaScript variables or even first party cookies (which may change during any website’s updates, making your variables fail).

GTM Implementation

After going through the details about tags, GTM, variables, data layers, and so on, you might be wondering about the timing of implementing these. Under which scenarios do you implement GTM or a data layer for your site or app?

Here are the different scenarios for firing GTM tags:

  1. When you only need to fire tags on the loading of web pages by using information of the URL and referrer. These tags are not required to be fired upon any user interactions on the pages. In such cases, you can simply add the relevant block of code to your website.
  2. When you only need to fire tags upon the loading of web pages by using more information than just the URL and referrer. For such cases, you need to add code to create the data layer for every page to push the information to it and make it available when the page loads.
  3. When you only need to fire a tag after some user interaction on the page, especially when you require data that is unavailable until any user activity occurs on the web page. For such cases, you need to add code to create the data layer and push the data to it. Later, you need to configure GTM to use the data layer upon the occurrence of certain events.

We hope that the above information about tags and their usage in GTM proves useful to you for the traffic tracking and marketing optimisation of your website or mobile app. Feel free to share your feedback or queries in the comments section below.

If you like my articles,