• Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

April 4, 2025

GTAG vs Google Tag Manager. What is the Difference? What to Choose?

Updated: April 4th, 2025

Google Tag (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 they serve.

 

Table of Contents

– Here’s what you will learn in this article –

  • 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
  • Should you use gtag.js in Google Tag Manager?
  • Final words

 

Video tutorial

If you prefer video content, take a look at the tutorial from my YouTube channel.

 

What is GTAG (Google Tag)?

When you create a new Google Analytics property, you have two options for how to install it on your website:

  • Via gtag.js (Google Tag)
  • or via Google Tag Manager (GTM)

I always recommend using the Google Tag Manager option, and later in this blog post, you will learn why.

So, what is Google Tag (GTAG)?

GTAG (or gtag.js) is a JavaScript code library that a developer can install on a website. When adding this tracking code, 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 used different tracking codes. Google Analytics was using analytics.js library while Google Ads was using conversion.js.

conversion.js and analytics.js

However, 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 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.

Subscribe and Get the Ebook - Mastering GA4 event tracking

What is Google Tag Manager?

Now let’s 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”). Whenever 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 the code that your developers had to add.

Adding that one tag to a site isn’t a big deal. You ask a developer, and he/she will do that (sometimes on the same day, sometimes over several days, but still reasonable because this has to be done only once).

What if you want to track actions that Google Analytics cannot do 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/her tasks, 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 is 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) in Google Tag Manager, and GTM will activate the tag for you.

All you need to do is 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 Meta Pixel, 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 and 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 also want to install Facebook Pixel and track conversions with Twitter Pixel?

Then you would need to ask a developer to implement that code directly in the source code of the website. And every time you need to make changes to 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 many more platforms, not just Google’s tools. Here are just several examples of what you can install with GTM:

  • Google Analytics
  • Facebook (Meta) Pixel
  • Microsoft Ads conversion tracking
  • Google Ads conversion tracking
  • Hotjar

The list could go on and on.

Subscribe and Get the Ebook - working with reports in ga4

#3. GTAG means working directly with the code. GTM – with user-friendly templates.

If you look at the documentation of GTAG, you will notice that all examples/instructions show how to edit the library’s code. 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, and go to Tags > New > Google 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 who 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 than nothing at all.

However, those strict developers are often not aware of the 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 safer, and marketers can keep some 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.

 

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), and 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-developers 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.

Even Google Tag Manager’s interface will tell you (if you try to add gtag to the Custom HTML tag) that you shouldn’t do this.

 

GTAG vs. Google Tag Manager: Final words

Hopefully, this clarifies 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 to just several Google 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.

 

Julius Fedorovicius
In Google Tag Manager Tips
17 COMMENTS
Carlos M. Díaz Honrado
  • Mar 25 2022
  • Reply

If you implement parallel measurement (WA and GA 4) how should gtag's asynchronous script go?
That is, this
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-1"></script>
A) Yes?
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-1&id=G-XXXXXXXXXX"></script>

    Julius Fedorovicius
    • Mar 25 2022
    • Reply

    That will be explained in my GA4 course https://www.analyticsmania.com/courses/google-analytics-4-course/

Modestas
  • Sep 8 2023
  • Reply

Thanks. I was one those who would get confused by these technologies and now it is much clearer.

vanuva
  • Sep 24 2023
  • Reply

Thanks for the great info on this and your videos - super helpful!

I had heard that GTM had a very slight effect on page load times - that the site using it loaded ever so slightly slower in some cases because it had to load GTM first, whereas the Javascript approach removed (or reduced) that friction. Your thoughts on that?

Yoshita Varshney
  • Nov 3 2023
  • Reply

Hi,

In one of the GA4 property I saw two tags One starting with G- and other from GT-. Can you please let me know from where do we get the Tags starting from GT-.

Tofandel
  • Aug 13 2024
  • Reply

I mean as you said, GTM is basically an open XSS vulnerability

You can inject absolutely whatever you want, unless you add a CSP on your website, because GTM is absolutely terrible for CSP management, because it injects the scripts inline instead of hosting a js file. That means in the case of a CSP you will need to whitelist every single script that anyone has added, and if they are ever changed the allow hash needs to be updated as well.

Also because tracking is often made by less experienced people, they either have no idea how to optimize the tags, which sometimes will result in duplicated scripts injected on the page, or wrong tracking etc. Or the events are tracked via page url instead of request result or button click which results in innacurate tracking

I'm one of those CTO's that view GTM as a huge security threat

If you want it done correctly, use gtag and a developer to setup the events

    Julius Fedorovicius
    • Aug 13 2024
    • Reply

    Or get more familiar with GTM features, for example, allowList and blockList which can be used limit what kind of scripts can be injected with GTM.

    Jake Peterson
    • Jan 29 2025
    • Reply

    Your information is inaccurate: Google has an extensive guide for safely using GTM with a CSP, while avoiding inline.

    Read about Noonce and Hash and everything here:

    https://developers.google.com/tag-platform/security/guides/csp

Zain Immu
  • Nov 26 2024
  • Reply

Doest It Works With Search Console Also Please Reply

    Julius Fedorovicius
    • Nov 26 2024
    • Reply

    What do you mean?

      Jake Peterson
      • Jan 29 2025
      • Reply

      Julius, we just dealt with this, I can lend a hand to Zain Immu:

      1) GTM does not work with Google Search Console in the same way it works with GA4. GSC is a standalone product and doesn't require any scripts.

      However, GTM is one of the six ways that user can prove site ownsership to Google in Google Search Consol.

      https://support.google.com/webmasters/answer/9008080?hl=en

      is one of the six ways that users

Cole Stark
  • Dec 4 2024
  • Reply

Hey Julius, I love your work–always helpful. Do you have any information on considerations when migrating from GTAG to GTM? How can I ensure historical GA data is maintained when removing the GTAG and reconnecting GA through the template GTM tag?

    Julius Fedorovicius
    • Dec 4 2024
    • Reply

    Historical data is not affected by such migration. All other details and tips on migration are explained in my paid GTM course for beginners

      Cole Stark
      • Dec 4 2024
      • Reply

      Thank you!!

Kuba
  • Jan 21 2025
  • Reply

Hi! we received info from Stape like below. And we here ;) i read article and don't understant. Stape Support write us:
"In general, we do not recommend using gtag and gtm at the same time. Please remove all unnecessary GTAG loads from your site."

And i'm little confused.
We tried Stape Server Side GTM > GA4 / gads etc.

But in GTM we add gtag for ga4/gads? like on your screen. We should have 0 gtag? or 1 in GTM is correct... Or i wrong understand O_o

    Julius Fedorovicius
    • Jan 21 2025
    • Reply

    What stape meant is that they do not recommend using gtag *in website's code* and gtm at the same time.

      Kuba
      • Jan 21 2025
      • Reply

      Thanks!
      Now we need told it to plugin developer and hope he understand. Thanks!

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Google Tag Manager Server-Side Tagging with Stape
  • How to Preserve Ad Click IDs with Server-side Tagging
  • LinkedIn Conversions API with Google Tag Manager. The Guide.
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings