-
Optimal placement of parameters for GTM-driven GA4 auto-tracking events
Hey folks! Just wanted to get your thoughts on how and where to mix in parameters with the GTM dataLayer model with the GA4 JS events (you know, the ones listed out here). Let’s say we’re talking about a ‘video_start’ event: am I right in thinking I can just push that event right onto the Data Layer and we’ll be able to start automatically recording from there? Like so:
dataLayer.push({event:'video_start'});
?But here’s where I keep hitting a wall: where do the parameter values come into play? I mean, can we just add them to the top layer of the Data Layer? Could it possibly look like this:
dataLayer.push({event:'video_start', video_title:'my title', video_url:'my-url'});
The thing is, I really want to keep the Data Layer clean and not cluttered. My ideal solution would be to squeeze those parameter values into one single property in the Data Layer. Kind of like this:
dataLayer.push({event:'video_start', video_params:{title:'my title', url:'my-url'}});
And then, get the GA4 GTM tags to correctly map the data layer variables to the corresponding GA4 parameters for these events. I mean, I could stop the automatic event tracking and do everything manually, but for now let’s stick to the automated route so we understand how the GTM GA4 tags work.
I can’t seem to find any official info (i.e. from Google themselves) about GA4-via-GTM detailing how events and parameters are handled through the Data Layer by the GA4 GTM tags. Do you maybe know how these mappings are managed in those ‘by default’ situations?
Log in to reply.