tag-manager
tag-manager copied to clipboard
The feature to "Actively synchronise from the Google Tag Manager data layer" interferes with GTM to fire events
GTM triggers don't work anymore, if "Actively synchronise from the Google Tag Manager data layer" in Matomo is enabled.
Hi @peterbo . Thank you for taking the time to create this issue. Could you please provide more details, maybe images or video to illustrate? Are you saying that triggers in your GTM instance are no longer functioning? Are you seeing any JS errors in your browser's console?
@peterbo We looked into it, but it isn't clear what the problem is? Could you please provide more information, images, videos, etc?
Hey everyone, i'm on Holiday until 28th of may and unable to provide a PoC before that. I'll post all needed information after my return.
@peterbo Thank you so much, we really appreciate your input. Feedback like this helps us improve the product for everyone. (snake14, glitchhunter66 and I are all on the same team that is looking at this).
Hello everyone, so here is a bit more information on the matter. The feature works by overwriting the "native" dataLayer.push method of the Google TagManager with kind of a proxy function in the Matomo TagManager.
This results in every dataLayer.push(object) being present in _mtm and the dataLayer.
The problem is, that the logic that is triggered in the "native" dataLayer.push function is not triggered, resulting in no triggers are being executed in GTM, although the object is being pushed to the dataLayer successfully.
I'm not sure how to show this to you, but it's easy to reproduce with a setup using GTM and MTM at the same time and both should react on an event that was pushed to the dataLayer. Only MTM will react to this trigger, if the feature "Actively synchronise from the Google Tag Manager data layer" is enabled.
I tried this method in the past with the same result. The only way I found to synchronyze both datalayers without interfering with any logic is to look into the dataLayer all xx milliseconds and apply all detected changes to _mtm.
Hi @peterbo . Thank you for elaborating on the issue so that we're sure what to look into. When Product team prioritises this issue, we can investigate alternative solutions for keeping both dataLayers synced without harming GTM event listeners. In the meantime, we'd be happy to review a PR if you find a solution.
Fix would be something like this, don't have the time to checkout and run the minifier properly at the moment. https://github.com/karlsve/tag-manager/compare/5.x-dev...patch-1
Fix would be something like this, don't have the time to checkout and run the minifier properly at the moment. karlsve/[email protected]
@karlsve Thanks for the patch, we would still need to plan this and test it, if everything works as expected.
Thank you again @karlsve . I have merged your commit into a new PR.
@peterbo Can you please temporarily apply the patch from PR #1039 and confirm whether it fixes the issue you've been experiencing?