I'm trying to set up the select_content
event as laid out in the GA4 Recommended Events page.
However, my current organization wants to use the dataLayer syntax to push this event to GTM instead of gtag.js. The way I've set it up looks like this:
const dataLayerObjectToPush: {
event: "select_content",
content_type: "type_string",
content_id: "id_string"
};
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(dataLayerObjectToPush);
However, when I send it through to be processed through GTM, the content_type
and content_id
values get stripped. What's happening here, and how can I make sure those values don't get removed?
I found the solution: I needed to set up the appropriate variables in Google Tag Manager, and link them to my select_content
event.