-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Google Analytics v4 (gtag) #2252
Comments
We have wanted to move analytics to a plugin for some time (which would make it easier for users to switch it out for another service of their choice). This would be a great opportunity to do that. As users would need to update their config to include the new Personally, the time I have available to work on MkDocs is very limited these days, so any contributions would help this alone. |
I just noticed that there are some references to this issue from the material theme. Rather than moving analytics to a plugin, another possibility would be to make the new The more I think about it, I'm not sure a plugin makes sense. All we need to do is insert a few lines of javascript into each page with the @squidfunk, do you have any comments on whether this would make more sense as a plugin or as a theme specific config option? |
That's definitely an option, but I first wanted to discuss this with you. IIRC, you were considering removing the top-level If you ask me, I'd be all for deprecating the |
I think that's an excellent plan. The deprecation notice should include a comment that Google is deprecating the old ID format. Let's pass on the blame for the change. 😁 We could raise the warning for two separate conditions: (1) when a user sets the
We'll plan on doing the same with the built-in themes and recommend third party themes do the same.
Not entirely, but it would move maintenance strictly to the built-in themes, which ensures that any details are theme specific. That eliminates any backward compatibility issues with third party themes in the future. As an aside, this move will also be more consistent. From time to time we receive a request for some feature and I respond that the feature should be implemented through a theme. An often cited counterargument is that analytics is not implemented through a theme. This change will eliminate that counterargument. |
Is there a link we can point to for this? |
|
Thanks @nemchik. That will be helpful to link to in the release notes. However, I was also looking for confirmation that "Google no longer allows creation of properties with the older analytics IDs." We don't want to make that claim unless we can confirm it. |
The note at the top of this page seems to discourage using the old IDs, but I get the sense that you can still create them and use them. |
I looked into this and actually found I was slightly mistaken. Google defaults to new accounts being created as GA4, but does still offer the ability to create property IDs for the older version of GA. They hide the option under the "advanced" button during creation. Also for existing accounts that do the upgrade it looks like a new property for GA4 is created, but the old one is still usable even after performing this upgrade. Collection of information will only happen on one or the other (depending on whether you have analytics.js or gtag.js on the page). When I first upgraded one of my properties to GA4 the old property ID disappeared so I thought this was an irreversible change, however it has now reappeared (I'm not crazy, I promise it was gone 😄 ). |
Based on the comments in the bottom section of this page, if you properly do an upgrade, the new and old IDs will be linked and the old data will continue to be updated from the new ID. However, the new ID will not have the old data transferred over. This is good to know as some users may want to continue to use the old data format. They can continue to do so. According to this, even new users can still create an old style ID and link it to the new |
I have a working and documented (but not fully tested) implementation in #2253. Any feedback is welcome. |
A new replacement option (theme.analytics.gtag) was added to the built-in themes. Multiple different services could be offered under theme.analytics. At this time only support for gtag exists, but more could be added in the future. Fixes #2252.
- Add a PEP 561 marker file (py.typed). - Run mypy during CI. - Update black to avoid pallets/click#2225 - Update mkdocs to avoid mkdocs/mkdocs#2799 - Disable mkdocs strict mode to avoid mkdocs/mkdocs#2252
Google recently introduces Analytics v4.
ga4 no longer provides IDs compatible with
analytics.js
which are in the formatUA-#####-#
ga4 now uses a new
gtag.js
and IDs in the formatG-ABC123
Google no longer allows creation of properties with the older analytics IDs. Existing Google Analytics properties can be upgraded and converted to ga4 which will replace their
UA-#####-#
ID with aG-ABC123
ID. There is no way to downgrade.Google is emailing existing users encouraging them to upgrade to ga4. To my knowledge at this time they have not announced any kind of cut off date for when migrating to ga4 must be completed.
Currently it is possible to use template overrides to put the new ga4 into an mkdocs site, however the
format is extremely convenient and easy to use (by comparison to the slightly more advanced setup of overrides).
For the purpose of making the transition possible without breaking existing setups without warning, I think it would be great to add
options to
mkdocs.yml
that would use the newgtag.js
which is documented by google to be implemented asThis would allow existing mkdocs users to continue using
google_analytics:
for as long as google continues to support it, or upgrade togtag:
very easily at their own discretion.Alternatively it would also probably be file to implement something in
google_analytics:
handling that uses gtag depending on the ID specified.The text was updated successfully, but these errors were encountered: