Learn business growth with Google Analytics 4 Forums Google Analytics 4 Integrating Google Tag(gtag) and Google Tag Manager Reply To: Integrating Google Tag(gtag) and Google Tag Manager

  • Scarlett

    Member
    3 May 2023 at 1:20 am

    Sure, let’s take a step back and look at what Google Tag Manager (GTM) and Google Analytics 4 (GA4)/gtag.js do.

    At the core, think of GTM as a “container” that can hold numerous tracking codes (including GA4/gtag.js). So, you put all your tracking code inside GTM, and then you only need to install GTM on your website once. That’s why it’s popular – you can manage multiple tags from one location.

    On the other hand, gtag.js is the JavaScript library that communicates directly with Google Analytics. It fires off the data you want to track to GA. You can run it independently, without GTM.

    Ideally, you should only use GTM. Put your GA4 tracking inside GTM, along with any other tracking codes you want. GTM smartly manages all the codes, tracks the data you want, and sends it to your Google Analytics in the most efficient way.

    But technically, you couldload both GTM and gtag.js separately on your site. While they won’t cause any syntax issues, it’s possible they could create some logical tracking conflicts. For instance, you may end up firing the same event twice – once from gtag.js and once from GTM – which can mess up your analytics. Also, they would use the same cookies.

    So in short, while you technically “can” use gtag.js and GTM together, it’s simpler, cleaner and more efficient to just use GTM and manage your GA4 tracking from there.