Closed Mercutio42 closed 1 year ago
Hi @Mercutio42 . Thank you for taking the time to create this issue. It looks like using an IIFE to insert the MTM script would be a good way to avoid polluting the global scope. Thank you for the excellent suggestion. I will mark this issue to be prioritised by our Product team.
Then the same for standard JavaScript tracking bootstrap code ;-)
Thank you for mentioning the regular JavaScript tracking code @heurteph-ei . I'm not sure when, but it appears to have already been removed from the global scope:
@Mercutio42 I went ahead and updated the Matomo Tag Manager code snippet while I was working on some other improvements in MTM. The changes were included in the Matomo 4.15.0 release.
Tag-Manager script declares variables in global context and might collide with other scripts
error: identifier 'd' ('g','s') has already been declared
might apply IIFE (function(){ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=''; s.parentNode.insertBefore(g,s); })();