Closed DarkLink571 closed 1 month ago
Hi @DarkLink571 . Thank you for taking the time to create this issue. Could we please get a little more information? For example, the script executing before MTM loads, is it using _mtm.push(...)
or is it using the GTM format dataLayer = [{...}];
?
Hi @snake14. I used the _mtm dataLayer.
Here is an example
_mtm = _mtm || []; _mtm.push({event: "testEvent"}); _mtm.push({{event: "testEvent", dlvariable: "testValue"})
Thank you for the example @DarkLink571 . In that case, I would say that it makes sense that the event is triggered twice as the dataLayer value would already be set when both events are triggered after MTM finishes loading. If those events were pushed after MTM were loaded, I would expect only the second event to trigger due to the dataLayer condition. You may want to make sure that the events aren't pushed until after MTM has loaded if you don't want the first event to trigger, like maybe pushing them as part of a Custom HTML tag. Any other recommendations @AltamashShaikh ?
akes sense that the event is triggered twice as the dataLayer value would already be set when both events are triggered after MTM finishes lo
@snake14 CustomHTML should do the trick :+1:
@DarkLink571 Does using a Custom HTML tag work for you? Please refer to previous comment.
@DarkLink571 any update ?
Closing this due to inactivity, @DarkLink571 Feel free to comment on this issue, if you are still facing any issues.
In some cases, datalayer pushes are made before the Tag Manager has loaded. These pushes may include event calls and setting of datalayer variables. But the pushes are not handled successively and it is possible for a datalayer variable to not have the intended value at the time the event is resolved.
Example: -Create a datalayer variable -Create a customEvent trigger with the variable as filter -Create any tag that uses that trigger -On the website run a script BEFORE the tag manager loads. This script pushes the event twice, the first time only the event, the second time with a fitting value for the variable. -The tag will fire twice, despite the condition should have been only fulfilled once.