-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Add support for google analytics v4 #8264
Conversation
This looks like a good PR! I haven't built/tested it, but glancing over the code it works how I would have expected it to. We'll have to update the Docs too. |
OK, @djatwood could you add a couple of lines to the relevant docs section below /docs in this repo? |
I'm happy to update the docs. I could also add gtag support to |
No, let's drop that, that creates too much stuff to maintain. I suggest that we mention that in the docs is that "for v4, use that other template". |
Alright I believe everything should be ready for review now. |
@djatwood, can you help me? I'm trying to use ga v4. So I'm setting the config .toml file as the docs, the var doNotTrack = false;
if (!doNotTrack) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-xxxxxxxxxx', { 'anonymize_ip': false });
} It's always false and doesn't execute the script. Sorry if I sound stupid, but I'm a noobie in all that stuff. |
I don't know if I have enough information. |
@natalianunez I'm having the same issue as you. Everything looks fine, and the request goes through with |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The Google analytics template doesn't work with Google Analytics v4 (gtag.js) #7954. v3 analytics.js is not depreciated so we should support both using
hasPrefix
to tell the difference.It should be noted that gtag uses the
async
attribute. Which is more likegoogle_analytics_async.html
. I'm not sure if we should move the changes to that template instead. The naming of the template is also confusing. See #8261.Privacy settings
anonymizeIP
andrespectDoNotTrack
are supported whileuseSessionStorage
is not. I could only find one document with instructions for session storage but in my testing it still set cookies.