mmuurr
mmuurr

Reputation: 1580

Where to put parameters for GA4 automatically-collected events via GTM

The documentation here lists a large collection of JS events that GA4 automatically collects. But the docs don't really specify how & where to integrate the event and the parameters with the GTM dataLayer model.

I assume by pushing a listed event to the Data Layer we get this out-of-the-box recording, e.g. dataLayer.push({event:'video_start'});. But even with that, the docs are not clear about where to push the parameter values ... should they all be pushed to the 'top' of the Data Layer, like so?:

dataLayer.push({event:'video_start', video_title:'my title', video_url:'my-url'});

Ideally I'd like to keep the Data Layer somewhat clean by pushing the parameters as sub-props into a single property on the Data Layer with something like:

dataLayer.push({event:'video_start', video_params:{title:'my title', url:'my-url'}});

, and then configure GA4 GTM tags to correctly map the Data Layer variables to the expected GA4 parameters for those events. I know I can disable some amount of automatic event tracking and do this all by hand, but I'd like to first understand exactly how the GTM GA4 tags are working.

I haven't been able to find any official (i.e. from Google) documentation for GA4-via-GTM covering the details about how events and parameters are handled via the Data Layer by the GA4 GTM tags. Does anyone here know how these mappings are handled in the default (i.e. "automatic") cases?

Upvotes: 2

Views: 985

Answers (1)

darrelltw
darrelltw

Reputation: 2372

I think for the Automatically collected events document shows is Google tell you if you see these events in your GA4 report. You can know what parameters they are sending along with the event.

These events they are collecting from their own JS listener. So you can only choose you want it or not. You can not modify the detail within it.


Another way is doing your own tracking. Like you said: You can push your own dataLayer and put it together in GTM to send to GA4.

DataLayer here is somewhere store the data and GTM can easily use.

And yes you can push the datalayer as you want like:

dataLayer.push({
  event:'video_start', 
  video_params:{
    title:'my title', 
    url:'my-url'
  }
});

In GTM: Then you can create some DataLayer variable for this enter image description here

enter image description here

The GA4 tag can be: enter image description here

Upvotes: 2

Related Questions