Learn business growth with Google Analytics 4 Forums Google Analytics 4 Trouble Tracking Events in GA4 When Using Tag Manager

  • Trouble Tracking Events in GA4 When Using Tag Manager

    Posted by Harry on 16 October 2022 at 10:08 am

    Just picture this, we’ve got GA4 up and running on our sites with a GTM GA4 Configuration tag. It’s smooth sailing for standard tracking, but here’s the kicker. We want to trigger a few custom events using the gtag('event', $eventName, $options) protocol. Sadly, they’ve decided to go incognito and aren’t tracking.

    Now listen to this, if we start off with a curtain raiser gtag('config', 'G-......'), then the later gtag('event', ...) calls get back on track. But there’s a glitch – we end up with a duplicate page_view and some of our cherished custom parameters get lost. It feels like this is shooting GTM’s purpose in the foot, plus it needs the ID in the site code, not configured through GTM. All of this somehow hints at a config error and not a real problem with loading GA4 via GTM to send non-GMT proxied events.

    If I had to hedge my bets, I’d say the GTM implementation and a direct one with gtag.js using gtag('config', ... aren’t really on the same page.

    And hey, we’d rather not set up each event as a GTM event. We need that freedom to toss any data from the front end.

    So here’s the million dollar question. Can we:

    • Get gtag('event', ...) calls on the same footing with GA as if gtag('config', ... has been called?
    • Set up a GTA trigger/tag that tosses raw data straight to GA4?
    Noah replied 12 months ago 3 Members · 2 Replies
  • 2 Replies
  • Gabriel

    Member
    14 March 2023 at 4:10 am

    Yes, it is possible to get gtag('event', ...) calls on the same footing with GA as if gtag('config', ...) has been called. The key lies in proper GTM configuration – you need to ensure the GA4 configuration tag runs on all pages before anything else so it can set up the necessary framework. This problem essentially stems from sequencing since every tag in GTM is run asynchronously or simultaneously. If GTM has not finished instantiating the GA4 config before the gtag('event', ...) call is made, the command will fail.

    As for setting up a GTA trigger/tag that tosses raw data straight to GA4, yes, you can do that too. GTM provides custom event triggers that could be used to send raw data to GA4 with a custom event tag. This requires a good understanding of the Event Builder in GA4, which allows you to create events based on user interactions and send them to GA4 via GTM.

  • Noah

    Member
    12 April 2023 at 9:03 am

    The user is seeking a solution whereby a series of custom events can be triggered on their website using the Google Analytic’s gtag (‘event’,…) protocol without having to initial with a gtag(‘config’,…). The issue they are experiencing is that the custom events aren’t populating without an initial config call and if they do use it then they end up with a duplicate page view.

    Additionally, they wish to avoid a GTM (Google Tag Manager) setup for each event, because they require the ability to send any data from the site’s front end and have it integrate seamlessly with GA4. The question then is centered around finding a solution or guidance on being able to get gtag(‘event’,…) calls to function at the same level as if it has been called from gtag(‘config’,…), and whether they can set up a GTM trigger/tag that carries raw data directly to GA4.

Log in to reply.