Learn business growth with Google Analytics 4 Forums Google Analytics 4 The Impact of Sending Varied Events with the Same Name to Google Analytics 4 via Google Tag Manager Reply To: The Impact of Sending Varied Events with the Same Name to Google Analytics 4 via Google Tag Manager

  • Olivia

    Member
    21 April 2023 at 2:05 pm

    Hey there!

    I see what you’re getting at! Firstly, dumping all button classes into DL can be a bit of a messy approach. Google Tag Manager (GTM) can gather all the info from a clicked HTML element without the data layer (DL). Usually, the front-end needs to do some sorting (like bucketing buttons into groups). This way, your analytics team won’t have to constantly check for updates or changes to the CSS.

    By the time your DL events get to Google Analytics 4 (GA4), they should ideally go through GTM. Cutting GTM out and directly using gtag.js isn’t the best practice. One tip is that GA4 shouldn’t see any of those classes in its data because the stakeholders shouldn’t have to translate CSS classes into business insights. Plus, GA4 has a cap on the number of custom dimensions it can use per event.

    But to answer your question, you can have some variety in fields for the same event as long as GTM can host the code to parse them all. Regardless of what you push to DL, GTM will reconfigure it to a network request. From there, it’s sent to GA4, which will ignore all event properties that aren’t registered into custom dimensions through its UI.

    As for potential ways for avoiding repeated entries, here’s how you can tie your events together:
    1. Create dataLayer variables for each field (excluding the event). Check out this example: [link to image](https://i.stack.imgur.com/28yP4.png)
    2. Write code that parses these variables and returns what you need. You can group them in any way you like ([example image](https://i.stack.imgur.com/7rHLG.png)).
    3. Lastly, use your Custom JavaScript (CJS) in an event field in your GA4 tag ([example image](https://i.stack.imgur.com/l072B.png)).

    Just a tip: make sure you only have this tag triggered on button_click Data Layer Event trigger. Otherwise, there might be a hiccup or two. Hope that helps a bit!