Learn business growth with Google Analytics 4 Forums Google Analytics 4 My GA4 events stopped sending after I added GTM to my website

  • My GA4 events stopped sending after I added GTM to my website

    Posted by Le on 3 September 2022 at 7:42 am

    Alright, let me lay it out here. We’ve got this Single Page Application (SPA) using a hardcoded GA4 tag. We’ve been doing a pretty cool job of sending custom events using the window.gtag('event', eventName, {...}) setup, with tons of these events baked right into our code.

    Not too long ago, we added GTM to the mix to tag on some other 3rd party tags. Yet, we decided to keep GA4 doing its own thing, outside GTM. Didn’t want to mess with rearranging our custom events on the GTM dashboard, you know? Why fix what ain’t broken!

    But here’s the kicker: Ever since GTM joined the party, our GA4 custom events have gone AWOL on our GA4 dashboard. They’re not showing up on the GTM dashboard either. Even tried playing nice and adding the GA4 tag onto GTM – no dice!

    What I need to know now is: is there any way to have both GTM & GA4 playing nice, carrying on separately, while my GA4 custom events (gtag('event', ...)) are still collected?

    Side note: If advised, I’m okay with removing the hardcoded GA4 tag from my code and shifting it onto GTM. Obviously, I’d want to keep using my gtag events and not have to redo all that work on the GTM UI.

    And hey, sorry if I’m a bit off in asking this. Still finding my way around GA.

    Jose replied 11 months, 2 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Michael

    Member
    5 July 2023 at 1:48 pm

    As Tony mentioned, it’s not best practice to use both GTM and gtag.js calls on the same page. It’s more effective to stick with GTM because it helps centralize all your analytics data – trying to use both can lead to complications like the one you’re experiencing. So, hanging on to your gtag() might actually be creating more tech debt in the long run.

    If you’d rather keep both sets of analytics, start by ensuring that GTM doesn’t have any active ga4 tags. Next, you can troubleshoot your gtag calls by looking into the console or network tab to check for any issues, and also make sure your gtag.js library is loading properly.

    If these steps don’t make the situation clearer, you can take screenshots and provide more information about your debugging process.

  • Jose

    Member
    8 July 2023 at 2:42 pm

    It’s quite possible that GTM (Google Tag Manager) and the hardcoded GA4 tag are interfering with each other. As such, you might have to consider consolidating your setup around a single implementation. In your case, it’s advisable to move the hardcoded GA4 tag into GTM as GTM can natively handle GA4 tags. For your custom events, instead of using gtag('event',...) in your code, you will need to make use of GTM’s event tag setup. You can continue triggering certain events in your single page application via Javascript. Ensure to use dataLayer.push to push the events into data layer and then instruct GTM to listen for that using the Custom Event trigger. It might initially seem a bit more work, but it will help debug issues in the future and provide a centralized platform for managing your all of your tags along with the custom events you need.

Log in to reply.