GTAG and Google Tag Manager are completely different beasts. But after seeing that people are looking for information about this topic, I have decided to write a blog post (and record a video).
In this article, I will compare GTAG vs Google Tag Manager, we will take a look at what they do and what purposes do they serve.
Table of Contents
+ Show table of contents +
What is GTAG?
Tracking code
What is Google Tag Manager?
GTAG vs GTM
#1. Google Tag Manager allows you to manage tracking codes
#2. GTAG supports only several Google’s products
#3. GTAG means working directly with the code
When does it make sense to use gtag.js?
Strict developers that do not allow tag management
An older project that heavily uses gtag.js
Additional questions you might have
Should you use gtag.js in Google Tag Manager?
Using Tag Assistant (legacy) for debugging? Read this
Video tutorial
If you prefer video content, take a look at the tutorial from my Youtube channel.
What is GTAG?
When you create a new Google Analytics property, you have two options how to install it on your website:
Via gtag.js
or via Google Tag Manager (GTM)
Personally, I always recommend using the Google Tag Manager option and later in this blog post, you will learn why.
So what is GTAG?
GTAG (or gtag.js) is a JavaScript code library that can be installed by a developer on a website. When this tracking code is added, it starts tracking standard events (like page_view and others).
In fact, gtag.js is used not only by Google Analytics (GA3 and GA4). Other Google products also rely on it, e.g. Google Ads.
Tracking code
In the past, Google Analytics and Google Ads were using different tracking codes. Google Analytics was using analytics.js library while Google Ads was using conversion.js.
But due to various changes in the industry, Google decided to choose a more unified approach, a single tracking code that is supported by multiple tools, gtag.js.
If you take a closer look at both codes in the screenshot below, you’ll notice that their structure is very similar.
<script async src=”https://www.googletagmanager.com/gtag/js?id=SOME_ID”></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag(‘js’, new Date());
They both load a script from googletagmanager.com (maybe this causes confusion and forces people to compare GTAG vs GTM).
This code initiates the library.
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag(‘js’, new Date());
Once this is done, your developers can modify the code and add additional commands. For example:
gtag(‘config’, ‘GA_MEASUREMENT_ID’);
This will send a page_view to a particular GA4 data stream.
Add this…
gtag(‘config’, ‘AW-XXXXXXXXX’);
…will add Google Ads tracking (needed for retargeting).
To learn more about the gtag and how to use it, read the official documentation.
What is Google Tag Manager?
Now let’s take a look at what Google Tag Manager is (and then we will compare gtag.js vs GTM). By the way, if you want to learn more about Google Tag Manager, take a look at this tutorial too.
Before we do that, let’s take a quick look at the world we used to live in (a.k.a. “without tag management”). Every time you want to install Google Analytics, it prompts you to add its JavaScript code (a.k.a. tag) on your website. Pretty standard, right? Gtag.js is that code that your developers had to add.
Adding that one tag to a site isn’t big of a deal. You just ask a developer and he/she will do that (sometimes on the same day, sometimes over the course of several days, but still reasonable because this has to be done only once).
What if you want to track actions that Google Analytics isn’t capable of doing automatically (e.g. form submissions, sales, etc.)
That’s where the developer (and the IT department) becomes a bottleneck. Since he/she is working on his own tasks/projects, marketing/analytics tasks often are a B priority, therefore you and your team have to wait. And wait a bit more. And more. Sometimes even for weeks.
That’s where the GTM saves the day.
Google Tag Manager is a tag management solution that acts as a middleman between a website and marketing/analytics tools. You (or your developer) can install it on a website and from that moment you are in charge of the tracking codes (in most cases).
Want to track a particular form and send that data to Google Analytics? No problem. Create a tag (tracking code) to Google Tag Manager and GTM will activate the tag for you.
All you need to do is to add your tracking codes to GTM and then configure rules when they should be activated (on page load, click, form submission, etc.).
Google Tag Manager supports not only Google’s products. It can be used to add other tracking codes too, like Facebook Pixel, or Hotjar, or something else.
If it is not clear how Google Tag Manager works, read/watch this tutorial.
GTAG vs Google Tag Manager
Now that we have taken a quick look at GTAG and GTM, let’s compare them.
#1. Google Tag Manager allows you to manage tracking codes. Gtag.js is one of those codes.
GTM is a central place where you can keep your tracking codes, manage them. When a page is loaded, Google Tag Manager will activate those codes based on your conditions (on page load, on purchase, on form submission, etc.).
One of the things that you can install is Google Analytics. And it uses gtag.js.
#2. GTAG supports only several Google’s products. GTM supports much more.
Gtag.js is used by tools like Google Analytics or Google Ads. It is a library that (after it is installed on a website) can load tracking codes related to the aforementioned platforms. But what if you want to also install Facebook Pixel, track conversions with Twitter pixel?
Then you would need to ask a developer to implement those codes too directly in the source code of the website. And every time you need some changes in your tracking setup, you would need to ask a developer to do that. This is time-consuming.
Google Tag Manager, on the other hand, supports way more platforms, not only Google’s tools. Here are just several examples of what you can install with GTM:
Google Analytics
Facebook Pixel
Microsoft Ads conversion tracking
Google Ads conversion tracking
Hotjar
The list could go on and on.
#3. GTAG means working directly with the code. GTM – with user-friendly templates.
If you take a look at the documentation of GTAG, you will notice that all examples/instructions show how to edit the code of the library. This means that:
You need to have at least some basic knowledge of coding
You need to have access to the website’s code if you plan to do the modifications yourself (or you will need to send the code snippets and instructions to a developer who is going to implement this)
In the meantime, things in Google Tag Manager are much friendlier (at least, in many cases).
Want to install Google Analytics? Log in to your Google Tag Manager account, go to Tags > New > GA4 Configuration tag.
You will see a form that looks like this.
Enter the information about what kind of information do you want to send (and where) and that’s it. After you test and publish this, GA4 will be activated on a website.
Instead of dealing with a code (and being afraid of messing things up), you just need to configure the tag by filling in the fields of a template.
When does it make sense to use gtag.js?
You are probably asking now “why use gtag.js at all when we have Google Tag Manager?”. Well, in some cases using GTAG might make sense.
Strict developers that do not allow tag management
Maybe you are working in a company with a very strict CTO or head of development who does not want to have any tag managers.
After all, GTM is a script injector that is a risk for a company (someone might add malicious code to GTM or a marketer might unintentionally add some untested code that breaks the website). Thus, the strict CTO has a full right to see GTM as a threat.
In such cases, strict companies decide to adopt tracking codes that can be controlled only by developers and not allow marketers to break stuff. That’s when gtag.js looks like an appealing option. It’s better to have at least some sort of tracking setup rather the nothing at all.
However, those strict developers are just not aware of powerful governance features that Google Tag Manager has to offer, for example:
User permissions (marketing can add codes but only someone else (more experienced) can publish those changes)
allowList and blockList (developer can limit what kind of tags can be added to the container, e.g. “only Google Analytics and Google Ads tags are allowed. Custom scripts are forbidden.)
Therefore, in my opinion, GTM is still a better option because developers can feel safe and marketers can keep some sort of flexibility. But if your company does not even want to hear about tag management, then gtag.js is an option for you.
An older project that heavily uses gtag.js
Another example that comes to my mind is an existing project that has A LOT of customized gtag.js code. Even though I would recommend migration from gtag to GTM, your company might not justify this kind of approach.
After all, this can cost a lot of time and resources, hence money. If that is your case, continuing to use GTAG might be the way to go.
Additional questions you might have
At this point, you might have some additional questions about GTAG vs Google Tag Manager. Let’s address them here. If you still have questions after reading the entire article, post a comment.
Should you use gtag.js in Google Tag Manager?
In Google Tag Manager there are a couple of ways how you can add tracking codes. One of them is templates (like the one of GA4 that I previously showed), the other one is a Custom HTML tag.
If you cannot find a readymade template for the tool you want to install, you can add that JavaScript via a Custom HTML tag.
And here is the question. How should you install Google Analytics 4 via Google Tag Manager? By using a GA4 tag template? Or by pasting gtag.js in the Custom HTML tag?
Even though it looks like gtag still can work in the Custom HTML tag, it is highly recommended to use the template instead, because:
Google keeps the GA4 templates updated
It is easier to manage tags for non-developer because you don’t need to mess with the code
The probability of error is lower when you work with a template
You can find a template by going to Templates > New.
Using Tag Assistant (legacy) for debugging? Read this
If you have Universal Analytics (GA3) installed on a website and that is done with a hardcoded gtag.js snippet, this part of the blog post is for you.
If you use Tag Assistant (legacy) Chrome extension to debug the setup, you will see this:
One row for Google Analytics, one row for Global site tag, and both of them have the same GA tracking ID.
Don’t worry, this is normal. When gtag.js is used to install GA3, it also loads the older version of the Google Analytics JavaScript library, called analytics.js.
Therefore, one row in Tag Assistant represents gtag.js and the other one analytics.js.
GTAG vs Google Tag Manager: Final words
Hopefully, this cleared some things about the differences between GTAG and GTM.
Personally, I always choose Google Tag Manager because it is more powerful, more flexible, and does not limit me just to several Google’s products.
So when you want to install Google Analytics, always start thinking about Google Tag Manager.
New to Google Tag Manager? Take a look at this tutorial for beginners.
The post GTAG vs Google Tag Manager. What is the Difference? What to Choose? appeared first on Analytics Mania.
Read MoreAnalytics Mania