Learn business growth with Google Analytics 4 Forums Google Analytics 4 Implementing GTM in Google Analytic V4 gtag.js

  • Implementing GTM in Google Analytic V4 gtag.js

    Posted by Noah on 6 May 2022 at 3:17 am

    Hey there! So, I’ve been looking into moving from analytics.js to gtag.js recently. I’ve noticed my JavaScript code has some GTM stuff in it. See here:

    ga('require', 'OPT_XXXXXXX');
    ga('require', 'GTM-XXXXXXX');
    

    So, here’s my puzzle – how do I swing implementing GTM when I’m working with Google Analytic V4’s gtag.js?

    Sophia replied 11 months ago 3 Members · 2 Replies
  • 2 Replies
  • Felix

    Member
    4 December 2022 at 9:22 am

    Sure thing! When it comes to switching from analytics.js to gtag.js, you’re basically dealing with a change in how Google Analytics integrates with Google Tag Manager. Basically, things have been streamlined a bit more. Rather than calling APIs directly, which can get a little sticky, you’re better off plopping a GTM container right into your site.

    Then, within that GTM container, you can manage your GA4 setup and event tags as they come up. It’s like telling gtag.js, “Hey, you just handle this when you need to.” Less stress for you!

    As for the ‘OPT_XXXXXXX’ bit, I’m not totally sure. Might be worth checking out the original vendor to see how this fits into the GTM/GA4 puzzle. Keep in mind that everything’s shifting towards GTM and GA4 playing nicely together, so any outside elements will want to align with that too. Good luck!

  • Sophia

    Member
    30 May 2023 at 12:38 pm

    In order to transition from analytics.js to gtag.js when you are using Google Tag Manager (GTM), you would need to create a new GA4 property in your Google Analytics. After that, inside GTM, you will have an option to install GA4 Setup Tag where you can enter your GA4 Measurement ID. You should also replace the existing GA3 tags with GA4 as well. After these changes, be sure to test and validate that your analytics are working correctly. It is recommended that you keep your Universal Analytics running in parallel with Google Analytics 4 for the time being, till GA4 matures, as GA4 is fundamentally different from the previous version.

Log in to reply.