Understanding the basics of Google Tag Manager — Review

Omar Quintanilla
7 min readApr 4, 2021

Introduction

Continuing with the CXL Digital Analytics degree, I decided to take a jump into the Google Tag Manager for beginners course. Why I did that? Because to better understand what the users are doing on our webpage, we need to set up the right events & conversions in GA4. Once we have that in motion, then we can analyze and extract insights in GA4 about user’s behaviors.

In this post, we will cover how to use Google Tag Manager in a basic way, so you can begin to set up custom events in GA4 and install third parties plug-ins on your web.

Google Tag Manager — components(tags, triggers, variables)

Tags

Tags can be confusing since there are a plethora of definitions on the internet about what a tag is in GTM. Plainly, tags are pieces of code (called snippets) that tell Google Tag Manager what to do.

Let’s see this with an example on GTM. When we click on Tags → New, we will see a lot of options on the right side. Each option is a tag that tells GTM what to do. The GA4:Global configuration tag, for example, tells GTM ‘Hey, I need you to send all the information about my web users to Google Analytics 4’. Looks simple, right? Well, indeed it is once you understand the fundamentals of GTM.

List of tags on GTM

Now, there are two types of tags in GTM: the built-in tags and the custom tags. They both do the same thing: they tell GTM what to do. The difference is that built-in tags are tags that have been already defined by GTM (e.g. GA4: Global Configuration tag) and custom tags are tags that you can customize to tell GTM what to do. For example, if you use Hubspot CRM, and you want to install the Hubspot Tracking code on your web to receive data from your users on Hubspot, you can use the custom HTML tag on GTM and set up the Hubspot tracking ID. Why would you need to use the custom HTML tag? Because there is not any built-in tag on GTM for Hubspot.

My best advice → Always ask you this question before implementing a tag on GTM: what do I want GTM to do? See this as your safety net and personal guide to install the correct tags on your site.

Triggers

Triggers can also be quite confusing, but always think of triggers as to when do I want GTM to take action? When do I want GTM to fire a tag? These questions are the fundamentals, and as with tags, they will guide you best on what triggers should you implement.

List of triggers on GTM

Let’s see the list of triggers available on GTM. We have four main categories of triggers:

  1. page view
  2. click
  3. user engagement
  4. other.

The first three categories are built-in triggers, and they offer an array of possibilities for us to define when do we want GTM to fire a tag; the last category is comprised of custom triggers that allow us to create triggers based on our own needs. As you can see, the types of triggers are quite similar to the types of tags: they both come with built-in and customizable tags/triggers.

Now, let’s see an example of how to implement a trigger. First, let’s click on Triggers → New. In the ‘This Trigger fires on’ section, GTM gives the users an option to decide when will this trigger fire. I think this is key for every GTM user because it gives extra control on when to program triggers to fire. We will see further in this post how to use this section, but for now, know that you can customize your triggers on when to fire thanks to the use of GTM variables.

Triggers overview

Variables

Finally, variables are key on GTM and they have one purpose: to store the information you are going to need in order to do the thing that you need to do (the tag) when you need to do it (the trigger).

As with tags and triggers, think of variables in the following way: what information do I need to store in GTM in order to do the things I want GTM to do? This self-asked question really helps a lot when determining what variables should you employ when configuring tags and triggers.

Let’s see an example of how to use variables when (1) creating tags and (2) creating triggers.

When you want to create a tag, variables are of immense help because they allow you to pass values to parameters on GA4 events. For example, if we want to create a GA4 event when someone views a webpage on our site, we need to select the GA4 event tag and then give a name to that event (in this example: page_visited). However, if we want further details, such as which page did the user view at our site (and we can know which page he viewed based on the URL of that page), we can create a parameter and grant a value to that parameter. Here variables come in place. GTM gives users the possibility to copy variable values (in this case the Page_URL value variable) directly to parameters in GA4.

So, we can basically say to GTM ‘Hey, I need you to create an event on GA4 when someone visits a webpage on my site, and I also need you to tell GA4 which page did the user view’. Simple as that.

This is a basic example of how variables can enhance the creation of tags, but the fundamentals remain the same for more complex tag creations you might implement.

Creating Tags on GTM

Now, when you want to create a trigger, variables also help a lot because they allow you to customize at a more deep level when to fire triggers.

A quick tip → when using variables to customize triggers, think of them as filters.

For example, if we want to create a ‘Just Link Clicks’ trigger in GTM, that trigger will fire whenever someone clicks on an element with a link embedded in it (e.g. a log-in CTA). However, as marketers, we don’t want this trigger to fire every time someone clicks on a link element (this is non-sense). Here variables come in place. GTM allows users to configure triggers to fire based on the values of variables.

We can configure the Just Link Clicks trigger in GTM to fire only when the element clicked is the log-in CTA button. And we can do this with the help of variables. As seen in the photo, we can tell GTM to fire only when the clicked element equals some text (in my example, it is when the clicked button equals ‘SEE OUR SHOP’, but you can customize it to your own needs).

Remember → variables serve as filters when creating triggers, they will help you tell GTM when to fire triggers!

Creating Triggers on GTM

Preview Mode — Debugging

With the key concepts in mind, we can move to test our new creations on preview mode. GTM has this amazing function where you can test whether your new implementations (tags, triggers, variables) are functioning as expected (or if you need to make some changes) before launching them public.

This is the common preview mode view. On the left, you will have a recount of all the events happening in order, and on the right, you will see the GTM elements (you can select whether you want to see tags, variables, errors, or the data layer).

You can go and explore what information you can find by clicking on tags, variables, the data layer, and errors; but for the purpose of this post, we will only show how to make a quick audit of your tags implementation.

Preview mode - Overview

In my example, I set a GA4 event tag to fire when a user stays longer than 25 seconds in any of my web pages. When I go to preview mode, I see the list of events happening on the right (look at event #4 — Timer 25x1). When I click on that event, I can see that my GA4 event tag fired correctly and I can see why — because all the trigger conditions were met.

So, just with this quick audit, now I am confident that my fired is set correctly and I can go publish it live to start collecting the data on GA4.

Preview mode -Tag audit example

Note: That was it for this post. In future publications, I will go deeper on how to use Tag Manager and how to use it in order to enhance your data collection and measurement on GA4.

--

--