Remove legacy Universal Analytics snippet from built-in themes - #84
Merged
Merged
Conversation
Google shut down Universal Analytics in 2023, so the 'analytics.js' snippet emitted by the built-in themes when the long-deprecated 'google_analytics' config option was set has been sending visitor data to a dead service. Remove the snippet from both the mkdocs and readthedocs themes. The 'google_analytics' option itself remains accepted so that existing configs and third-party themes that read it keep working, but its deprecation warning now states that it has no effect on the built-in themes and points to the theme's 'analytics.gtag' option (Google Analytics 4) or to overriding the 'analytics' template block. Builds with '--strict' will fail on the warning, as before. Also add a documentation example showing how to plug in any analytics service by overriding the 'analytics' template block. Addresses upstream issue mkdocs/mkdocs#3630.
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Google shut down Universal Analytics in 2023, so the
analytics.jssnippet emitted by the built-in themes when the long-deprecatedgoogle_analyticsconfig option was set has been sending visitor data to a dead service. This removes the snippet from both themkdocsandreadthedocsthemes.The
google_analyticsoption itself remains accepted so that existing configs and third-party themes that read it keep working, but its deprecation warning now states that it has no effect on the built-in themes:Builds with
--strictfail on the warning, as before. The moderntheme.analytics.gtag(Google Analytics 4) option is unchanged.Also adds a documentation example under "Overriding Template Blocks" showing how to plug in any analytics service by overriding the
analyticsblock — the approach the upstream issue recommends.Verified by building sites with both themes: with
google_analyticsset, output contains no analytics scripts and the warning above is emitted; withanalytics.gtagset, the gtag snippet is still rendered. Build/theme/config test suites pass (394 tests).Related Issue
Addresses upstream mkdocs/mkdocs#3630 (also related upstream: mkdocs/mkdocs#1794, mkdocs/mkdocs#2101).
Checklist
docs/about/release-notes.mdupdated (if applicable)🤖 Generated with Claude Code
https://claude.ai/code/session_018Hw7x9BxxpuKiLkzjLczp9
Generated by Claude Code