0

I saw a post for the same problem here: GTM - variable '_event' - return type and value is undefined

Simo Ahava (who I have immense respect for and is responsible for a majority of my knowledge of GTM) responded saying it's just a UI bug and the custom event triggers should still fire.

However, I am experiencing the same issue and cannot get custom event triggers to fire.

Here is what I see on my end:

In the data layer, GTM is receiving custom events for several things. In this example, an event called "task_event" screenshot of task_event in GTM Tag Assistant waterfall

I have a tag set to fire on this event, but it doesn't. When I review the firing triggers I see that the trigger didn't fire because "null equals task_event"

Screenshot of failed firing trigger

In the variables screen for the same event, the values for "Return Type" and "Value" in the variable "_event" are undefined. Screenshot of undefined _event variable

The same is true for the variable called "Event", though I'm not sure what the difference between the two is. Screenshot of undefined Event variable

This issue is happening for all custom events, not just "task_event". For what it's worth, I've created data layer variables for various other values from this datalayer event and they're all working properly.

Can't seem to find any answers about this, so any feedback is greatly appreciated.

EDIT: Adding a screenshot of the GTM trigger itself in case it's helpful Screenshot of Custom Event trigger

1 Answer 1

1

Make sure the environment and container of the GTM that's on the site is the same that you're previewing. Also make sure the workspace you're previewing is the correct workspace.

Why do you have the Container Loaded event after the task_event? If it's the same container reloading... Check the dataLayer too, see if anything clears it. Still, the event should work syncly or close enough to that from the preview perspective, so even if you have some odd reloads after the event, that shouldn't justify the issues with the event.

Gtag could probably interfere with GTM in this way? So if you're manually loading gtag.js and using it's api, you should stop. Move all that logic into GTM.

Preview, however, may be bugged. As Simo indicated, if the preview returns the current event value rather than the one that fired on the actual event, then reloading the DL or GTM would cause something like that. Check if that tag actually fires. Deploy some console log as CHTML and check if it's in the dom, or check the console.

Anyhow, check all these things, try fixing the mess with container reloading. If nothing helps, then maybe share the preview link? I'd like to see it myself. Maybe you're looking in wrong places.

3
  • Thanks for your response. Confirmed that it's the correct container, environment, and workspace. Unsure about task_event firing before Container Loaded - I actually haven't been able to replicate this since. Gtag shouldn't be installed. Just to clarify, preview is returning an undefined event, not a different event. Can you tell me more about how I would use console logs to troubleshoot? This container is installed on a third party tool that I don't have access to, so I might just have to ask them to check their implementation. Commented Jun 26 at 17:28
  • If Simo's right, it's the preview problem and the tag still fires. Replace the tag with something like <script>console.log("@@@ Debugging: test-event fired the tag!")</script> Then open preview, fire the event, then check the console for your log or check the DOM for your script.
    – BNazaruk
    Commented Jun 26 at 17:48
  • That's a great idea, thank you. Ultimately it seems most GTM variables were not on the whitelist for this specific tool, so I asked them to whitelist Custom Event. Hopefully that was the issue. I really appreciate your help though. Commented Jun 26 at 21:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.