Mon, May 13, 2019
The original article was written on May 13, 2019, and it focused on sending data to Google Analytics Universal. However, during the migration of the blog to a new CMS, I decided to update the content to reflect the current version — Google Analytics 4.
Google Tag Manager is one of those tools that can make your life simpler, more efficient, and in some cases, even bring in extra profit.
"Why are you still struggling with tracking codes, writing massive specs, and waiting for your developer to implement them? Just use Google Tag Manager and make your life easier!" — This is something many marketers have heard before finally adopting this tool for their business needs.
Sounds familiar? You need to add a tracking code to the website, so you write a task for the developer... and then wait... and wait... and wait?
If yes — this article is for you ;)
Google Tag Manager (also known as GTM) is a convenient — and most importantly, free — tag management system that allows you to add various useful code snippets directly to your site. GTM includes dozens of pre-configured tag templates that don’t require any custom coding. Below, we’ll cover the GTM basics:
One major reason to use it is that you no longer have to depend on a developer (who often isn't even yours but outsourced) to install the necessary codes on your site. With GTM, you can do it yourself without deep technical knowledge. In other words, once the GTM script is on your website, you can quickly install other Google tags (like Google Tag for GA4) or third-party scripts/pixels (e.g., Facebook Pixel) with just a few clicks.
This is especially useful if you like testing and exploring new ways to improve conversion on your site. For example, if you're curious about how users interact with your site, you can install Hotjar through GTM — without involving a developer.
Other benefits include faster site loading, more accurate analytics, and much more.
It only takes a few simple steps:
Before starting to work with Google Tag Manager, you need to install it on your website. There are several options here:
In the end, when you created the container, you should have seen the following window:
This window describes everything your developer needs to do to install it. Simply copy the information from this window into a file and send it for implementation.
If you accidentally closed this window, you can find the instructions by clicking on the container ID at the top of the menu.
Of course, writing the tech spec is only half the job. You need to make sure the codes are installed correctly. Here, like in The Matrix, you have two options:
<head>
and the other in <body>
, as described in the tech spec for the developer:Now that GTM is installed on our site, it’s time to get acquainted with the main entities we’ll be working with.
Since we’re studying a tag management tool, it makes sense to start our introduction with this entity.
A tag is a piece of code that you place on your website. You can use built-in templates to configure tags (e.g., for Google Analytics 4 or Hotjar), or take a more custom approach with Custom HTML or Custom Image tags.
In other words, if you want to add some tracking code to your site, you need to create a tag with specific settings. For example, to install the Google Analytics 4 code using GTM, you need to create the following tag:
You can read more about tags in the article “Tags in Google Tag Manager. A guide for beginners and beyond.”
When creating a tag, besides the tag configuration block, there’s also a second block called triggers.
A trigger is a condition for when a tag (code snippet) should fire. For example, if we want to install the Google Analytics code, then according to the instructions it should be placed on every page of our site. So we’ll use the All Pages trigger.
In other words, if we want to implement some tracking code on the website, we must perform just two steps:
Each of these points deserves attention, because you don’t want the form submission event to trigger on every page load, right?
And there’s another entity that you can live without, but which makes work much easier — the Variable.
To simplify, a variable can be imagined as a key-value pair. The key is the variable name. While working with GTM, you’ll find two types of variables: built-in and user-defined.
As the name suggests, built-in variables exist in the tag manager by default. An example is the Page URL variable, which stores the URL of the current page.
Built-in variables can be further divided into two categories: enabled by default and those you need to enable manually. To access the latter, click the Configure button in the upper right corner:
And check the boxes next to the variables you want to enable:
Built-in variables mainly store technical details about the action performed. For example, during a click event, the Click Classes variable will store the class of the button clicked; Click Text will store the text on that button.
If the built-in variable info isn’t enough and you want to store some custom data, you can create a user-defined variable. For instance, we might have a variable called “GA4 – G-XXXXXXXXXX” where we store the Google Analytics 4 ID with the value G-XXXXXXXXXX. In this case, we won’t have to go back to our GA4 account each time to find the ID.
Of course, it’s difficult to explain all even the basic concepts of the tag manager in a single article. So if you want to continue learning about this topic and how to track different user actions on your site using GTM, I recommend checking out the following articles from this blog:
If you enjoyed this content, subscribe to my LinkedIn page.
I also run a LinkedIn newsletter with fresh analytics updates every two weeks — here’s the link to join.
Web Analyst, Marketer