Skip to content

Not working with Google Analytics 4 #7662

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

Closed
bcb opened this issue Nov 12, 2020 · 7 comments · Fixed by #7691
Closed

Not working with Google Analytics 4 #7662

bcb opened this issue Nov 12, 2020 · 7 comments · Fixed by #7691
Assignees
Labels
Bug A bug

Comments

@bcb
Copy link

bcb commented Nov 12, 2020

Details

Expected Result

Google Analytics 4 launched recently and I upgraded. Updated my GA code in both the RTD web UI and in conf.py, expecting to see stats.

Actual Result

Getting zeroes in GA.

Screen Shot 2020-11-12 at 7 48 26 pm

@ericholscher
Copy link
Member

ericholscher commented Nov 12, 2020

Does your analytics code look like UA- or something different? I'm guessing we need a new JS client for the updated analytics.

Our current analytics code is here: https://github.com/readthedocs/readthedocs.org/blob/master/media/javascript/readthedocs-analytics.js -- is there a new client JS for GA4?

@bcb
Copy link
Author

bcb commented Nov 12, 2020

Yes, the javascript for GA4 is here:
https://developers.google.com/analytics/devguides/collection/ga4

The UA- codes are the old ids, the new one starts with G-.

@davidfischer davidfischer self-assigned this Nov 13, 2020
@stsewd stsewd added the Bug A bug label Nov 19, 2020
@JuanDCG
Copy link

JuanDCG commented Nov 23, 2020

I've the same problem, code start with G- and it doesn't works with it in RTD web UI and in conf.py.

Thanks for fixing the bug.

@davidfischer
Copy link
Contributor

I am looking at this and I have a few bits to work out before we have a solution. In the current setup, Read the Docs attaches its own GA code as well as any user analytics code. Hopefully we can still support that.

Other visitors can disable GA by using the do not track feature of their browser and project authors can disable GA entirely for their documentation. These features should still be supported.

  • It looks like the new snippet supports the old (UA-*)and new (G-*) properties. Here's how to add multiple codes and here's how to route events like custom events.
  • Read the Docs reduces the GA cookie time in the interest of privacy. It looks like this is how that works.
  • Here's the guide on custom dimensions. Read the Docs uses these to record things like the project slug and documentation type (Sphinx, MkDocs). Ideally these custom dimensions only apply to our analytics code.

@davidfischer
Copy link
Contributor

I have a pending fix if any of the affected users would like to take a look: #7691

@stsewd
Copy link
Member

stsewd commented Dec 8, 2020

@bcb the fix is live now, can you confirm is working for you?

@bcb
Copy link
Author

bcb commented Dec 10, 2020

Yes I’m seeing numbers now.

One small note, you might want a separate field for each GA code, because I think 4 is meant to be able to run alongside the previous generation, so it’s possible someone might want to have both at once. But for me, I just went straight to using 4.

Thanks for resolving!

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

Successfully merging a pull request may close this issue.

5 participants