I am actually working on a large web application, which was initially built with Symfony/Twig, and that is gradually refactored using React. But since I am using React, some of my pages get no "views" in Google Tag Manager (GTM).
I followed this guide to use GTM in React. But I have a lot (tens) of Tags and Triggers in GTM, based on the 3 native events "Container loaded" (gtm.js
), "DOM Ready" (gtm.dom
) and "Window Loaded" (gtm.load
).
The first solution (from the guide) is to add a new custom trigger (based on History Source) and link our tags on this new trigger. But since I have too many tags, this is not a satisfying solution.
The second solution is to manually trigger events, using the datalayer. This works fine, I can easily trigger the "DOM Ready" and "Window Loaded" events. But it does not work as expected for "Container Loaded". I guess that GTM does not handle this event more than once per page load.
So, here are my questions:
- Is it possible to "fake a reload" in GTM (so that GTM act like if I opened a new page)?
- Or is it possible to trigger "Container Loaded" (
gtm.js
) multiple times?
Screenshot of a "normal" Container Loaded trigger:
Screenshot of a manually called Container Loaded trigger (from React):
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…