8

I'm using Google Tag Manager (aka: GTM) to send events to my Google Analytics 4 account, some of them are custom that developers send thru the code like that:

dataLayer.push({
    event: 'CA:some-event',
    a: 1, // custom param
    b: 2  // custom param
})

I defined a Trigger in GTM to catch all events that start with "CA:*" (as regex) and then i defined a new Tag: "Google Analytics: GA4 Event" to be invoked when the trigger fired and send the event to GA4.

I'm getting the events successfully to my GA4 account but the problem is that all params, a and b in my example, are not sent as they are not mapped to be sent from GTM layer within the GA event.

I can define Variables in GTM specifically for them but it's not dynamic and it means that every time a developer needs to send a new custom event he'll need to go to the GTM account (and usually they don't have access to it), add the variables and it makes the whole solution semi-automatic and not dynamic enough.

I hope it's clear.

Any suggestions here?

0

3 Answers 3

2

i ended with the following solution:

  1. I changed the way I'm sending the event to be:
dataLayer.push({
    event: 'CA:some-event',
    data: {
        a: 1, // custom param
        b: 2  // custom param
    }
})
  1. set a variable in GTM called "Custom Event Data" based on the data property of the event

  2. set the GA4 event tag to send it to GA4

  3. set a new Custom Dimension in GA4 called "Custom Event Data" based on the data property

The limitation is that I cannot use a and b directly in GA4 as a native fields but at least I can see the variation of them in the GA4 reports

Sign up to request clarification or add additional context in comments.

1 Comment

I'm still testing this, but FYI for others... I wasn't sure what type of variable to use, but it seems that "Data Layer Variable" does the trick, and when editing the variable set the "Data Layer Variable Name" to "data" (or whatever you want—I made it customEventData to be more specific).
0

Unfortunately there is no easy way to manage GTM as the way you want. Hope they can allow us to use just JavaScript object to send as event parameter. (They only allow Ecommerce DataLayer at this time)

But looks like your developer can decide the event parameter themselves. So the option here is if they don't have access to GTM. They can just tell the one who is handling the GTM that their new implementation. So the GTM guy can modify based on it.

If your scenario is the changing is a lot and it really need to be automatic. Then GTM API might be the way. (But it also take some times for developer to integrate with it)


I used to manage more than 10+ properties and more than 30+ new events needs to add in a week.

So I choose Google Sheet(with Google App Script) to manage the GTM more easily.

The point here is there are still some ways to make it more automatic. Just need to leverage is it worth it do develop.

Comments

0

GTM as of now has "Event Settings" variables where you can define multiple custom data properties and reuse them, somewhat alleviating the PITA of mapping custom properties for each individual tag.

https://support.google.com/tagmanager/answer/13438771?hl=en

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.