-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby-plugin-google-gtag): correct script to match google's current #36993
Conversation
https://developers.google.com/tag-platform/gtagjs/install shows a different snippet: window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date()); Can you also update all the docs that include this? Thanks! |
Yes, indeed, I forgot to remove
Will do! |
update all the docs including the new gtag script
@LekoArts should be done now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
Came across this other older PR while troubleshooting an error in Safari and DuckDuckGo Browser: #11431, and appears to be the reason the Not questioning the decision of removing it, just wanted to add context in case it was missing at the time of merging, or to anybody who comes across this issue again. |
@joaquingatica the changes in this PR are in line with GA's current manual install instructions of the GA4 tag, and in that snippet they only check I believe it must be happening for some other reason, most probably a browser plugin or privacy settings - this question on SO may provide some valid answers to such cases. |
When taking the script from GA directly, it doesn't have this additional check for
window.dataLayer
, also the related documentation shows it without it.gatsby/packages/gatsby-script/README.md
Line 40 in fc299ec
gatsby/docs/docs/reference/built-in-components/gatsby-script.md
Line 157 in fc299ec