Learn business growth with Google Analytics 4 Forums Google Analytics 4 Implementing GA4 Initialization and Utilizing GTM for Event Tracking

  • Implementing GA4 Initialization and Utilizing GTM for Event Tracking

    Posted by Sophia on 25 March 2023 at 10:05 pm

    Hey folks, I need a hand getting the GA4 property up and running using the command gtag(‘config’,). I’m trying to add a few parameters myself, like clientID and SessionID for cross-domain tracking via an iframe. Is anyone else doing this too?

    I’m a bit stumped on what to do next. I’ve got the GA4 property initiated with the gtag command, but I’m not sure how to use the GTM to send events to the GA4 property. Doesn’t a GA4 configuration tag also need to be in the GTM to send events to a property? Won’t that re-initialize the GA4 property?

    So here’s what I tried. I put the GA4 configuration tag into the GTM, and then I initialized the GA4 again using the gtag command in custom HTML. But it’s just not outputting the right data about the clientId and SessionID. Any ideas?

    Mia replied 11 months, 1 week ago 3 Members · 2 Replies
  • 2 Replies
  • Elizabeth

    Member
    23 May 2023 at 1:20 am

    From your question, it seems that you are trying to connect Google Analytics 4 (GA4) and Google Tag Manager (GTM) for cross-domain tracking and event triggering. The ‘gtag’ command you mentioned is a part of Google’s Global Site Tag (gtag.js) system, which is used to unify tracking systems across Google’s suite of tools.

    To initiate GA4, you’ll need to use the ‘config’ command with your GA4 property ID. This should initialize tracking. Configuring it through GTM as well may cause duplication or override your configurations.

    Instead, you can use GTM to manage the custom events you want to track. For cross-domain tracking, you need to have GA’s ‘Linker’ setting enabled on both domains, and they need to be specified in the Referral Exclusion List.

    The clientID and SessionID should be automatically handled by Google Analytics. If you’re not finding them in your reports, there may be an issue with the setup.

    In short, use ‘gtag(config)’ to start tracking with GA4, use GTM for custom events, and enable ‘Linker’ for cross-domain tracking. Check your setup if clientID and SessionID aren’t appearing correctly. Technical help may be needed to figure out the exact issue.

  • Mia

    Member
    4 June 2023 at 4:10 pm

    It seems like you are looking to track your iframe’s interaction with your GA4 property. Firstly, make sure your gtag(‘config’,) command includes all the parameters you want to track like clientID and SessionID.

    To set up cross-domain tracking through GTM, you’ll indeed need a GA4 configuration tag. However, initializing the GA4 property again in your custom HTML might lead to re-initialization, which is not the recommended way.

    Instead, you should use the GA4 configuration tag in GTM and update that tag with your parameters. Adding your parameters there should send the information you need to GA4 when the tag fires. When it comes to event tracking, you need additional GA4 event tags in GTM for specific user interactions like clicks or form submissions.

    So, instead of initializing GA4 again inside a custom HTML tag, consider using the Data Layer to push your clientID and SessionID, then use these values in your GA4 configuration tag. Remember that you’ll need to include these details in the GA4 configuration tag within Google Tag Manager, not in a custom HTML tag as that could indeed re-initialize your GA4 property.

Log in to reply.