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

fix: assign dataLayer from gtag to the datalayers object #56

Closed

Conversation

huang-julien
Copy link
Contributor

Hey 👋

This PR fix #55 . The issue is that we were creating our own dataLayers object to store the arrays from gtm. One thing was missing which is the l query parameter in the external script : https://developers.google.com/tag-platform/tag-manager/datalayer

"strategy": "worker",
"location": "head",
"action": "append",
"key": "gtag"
},
{
"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}}')",
"code": "window.dataLayers=window.dataLayers||{};window.dataLayers['{{dataLayerName}}']=window.dataLayers['{{dataLayerName}}']||window.{{dataLayerName}}||[];window.gtag=function gtag(){window.dataLayers['{{dataLayerName}}'].push(arguments);};window.gtag('js',new Date());window.gtag('config','{{id}}')",
"params": ["id", "dataLayerName"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataLayerName should probably be renamed to l to keep the naming consistent ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also because everyone is probably expecting to use one name for datalayer. l has the JSDoc added anyway so users won't have to look for the meaning of l

@huang-julien
Copy link
Contributor Author

probably needs to wait #54 to be merged first

@huang-julien
Copy link
Contributor Author

closing since we're going to rollback

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 this pull request may close these issues.

GTM and GTAG datalayers does not work anymore
1 participant