Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtag() is getting overriden when using multiple gtm or ga with different dataLayers #53

Closed
huang-julien opened this issue Jul 21, 2024 · 1 comment · Fixed by #54
Closed

Comments

@huang-julien
Copy link
Contributor

reproduction
nuxt/scripts#173

When using dataLayers, gtag defined by tpc is overriden due to window.gtag=function gtag(){window.dataLayers['{{dataLayerName}}'].push(arguments);} at

"code": "window.dataLayers=window.dataLayers||{};window.dataLayers['{{dataLayerName}}']=window.dataLayers['{{dataLayerName}}']||[];window.gtag=function gtag(){window.dataLayers['{{dataLayerName}}'].push(arguments);};window.gtag('js',new Date());window.gtag('config','{{id}}')",

This prevent users to have multiple dataLayers.

@huang-julien
Copy link
Contributor Author

Can we drop gtag() and let users handle the push function by themselves ? this is probably safer as gtag() is only a wrapper around the datalayer's push function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant