Learn business growth with Google Analytics 4 Forums Google Analytics 4 Sending Custom Events with Parameters from Google Tag Manager to Google Analytics in a Dynamic Manner

  • Sending Custom Events with Parameters from Google Tag Manager to Google Analytics in a Dynamic Manner

    Posted by Mia on 16 February 2023 at 3:49 am

    I’m using Google Tag Manager to send info to my Google Analytics 4 account and some of the stuff that my devs send through the code, like such: dataLayer.push({ event: ‘CA:some-event’, a: 1, b: 2}) isn’t getting through to GA4. I made a trigger to catch these kinds of events and a new tag but I’m running into trouble when I try to map these extra parameters in GTM. I can define them but it’s a pain because every time a developer wants to add something new, they’d need to go into GTM. Any solutions you guys can think of?

    Felix replied 1 year ago 3 Members · 2 Replies
  • 2 Replies
  • Sophie

    Member
    26 May 2023 at 6:42 pm

    Sure, I’d be happy to give you a more everyday breakdown.

    Essentially, it’s a bit of a hassle to configure Google Tag Manager (GTM) the way you want to, primarily because it doesn’t allow using just JavaScript objects to send as event parameters, with the current exception of Ecommerce DataLayer.

    However, the apparent good news is your developer can decide on the event parameter themselves. This means they can share their new implementations with whoever is handling the GTM at your end, so it can be adjusted accordingly.

    There might be a little more efficiency if changes are frequent and need to be automated. The GTM API would come into play here. But it’s worth noting that there would be some extra time for developers to integrate with it.

    Speaking from experience, I was once juggling over 10 properties and adding more than 30 new events per week. I found Google Sheets, in combination with Google App Script, very convenient for managing GTM.

    The takeaway is there surely are ways to make the process more automated. The decision comes down to whether it’s worth the time and effort necessary for implementation.

  • Felix

    Member
    12 June 2023 at 4:22 pm

    Absolutely, the best way to dynamically capture these custom parameters and send them to Google Analytics 4 is by taking advantage of data layer variables in Google Tag Manager.

    You can start by creating a data layer variable for each custom parameter. Go to Variables, create a new one, and designate it as a data layer variable. Enter the name of the parameter as the Data Layer Variable Name (e.g., “a” or “b”).

    Next, include these data layer variables as fields in your Google Analytics 4 Event tag. Go to the tag, click on “More Settings” and then “Fields to Set”. Specify the name of your data layer variable (like “a” or “b”) and input the corresponding value as {{a}} or {{b}}. Be sure to do this for each custom parameter.

    After implementing these changes, you’ll need to publish your updates in Google Tag Manager. Now whenever an event is pushed to the data layer, these custom parameters will be included as well and sent to Google Analytics 4. This process eliminates the need for the developers to manually update the GA4 Event tag every time they want to add a new parameter.

    One important note about this approach: Keep your parameters consistent across all events in order to prevent any discrepancies in Google Analytics 4.

Log in to reply.