Skip to content

Deprecate google_analytics config option. - #2253

Merged
waylan merged 8 commits into
mkdocs:masterfrom
waylan:gtag
Jun 2, 2021
Merged

waylan merged 8 commits into
mkdocs:masterfrom
waylan:gtag

Conversation

@waylan

@waylan waylan commented Dec 14, 2020

Copy link
Copy Markdown
Contributor

This implements the plan discussed in #2252.

On the built-in themes I added a new option theme.analytics.gtag. See the documentation for details. The idea is that 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.

I made some changes and additions to the Deprecated option validator which still needs tests.

We also need to upgrade the Google Analytics account for https://mkdocs.org to use the new GA4 ID. Until we do, builds will issue a warning:

$ mkdocs build
WARNING -  Config value: 'google_analytics'. Warning: The configuration option 
google_analytics has been deprecated and will be removed in a future release o
f MkDocs. See the options available on your theme for an alternative.
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/waylan/Code/mkdocs/site
INFO    -  Documentation built in 0.99 seconds

@squidfunk

squidfunk commented Dec 15, 2020 •

Copy link
Copy Markdown
Contributor

I haven't tested it but the proposal sounds great. I also like the extensible approach of theme.analytics.* and will implement it in Material for MkDocs.

@waylan

waylan commented Dec 16, 2020 •

Copy link
Copy Markdown
Contributor Author

The integration tests will continue to fail until we update our own config to use the new gtag (they build the docs in strict mode).

In all other respects, this should be ready to go.

@waylan

waylan commented Dec 16, 2020 •

Copy link
Copy Markdown
Contributor Author

@tomchristie can we get the Google Analytics account for https://mkdocs.org upgraded to V4 (as documented here)? We then need the G-ABC123 format ID to put in the config file.

diff --git a/mkdocs.yml b/mkdocs.yml
index f120128f..1aed065e 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -8,6 +8,7 @@ edit_uri: ""

 theme:
     name: mkdocs
+    analytics: {gtag: 'G-ABC123'}
     highlightjs: true
     hljs_languages:
         - yaml
@@ -40,7 +41,6 @@ markdown_extensions:
         repo: mkdocs

 copyright: Copyright &copy; 2014 <a href="https://twitter.com/_tomchristie">Tom Christie</a>, Maintained by the <a href="/about/release-notes/#maintenance-team">MkDocs Team</a>.
-google_analytics: ['UA-27795084-5', 'mkdocs.org']

 plugins:
     - search

@waylan waylan linked an issue Dec 16, 2020 that may be closed by this pull request
@alex-klimov

Copy link
Copy Markdown

Hi guys, what is the status? Do you think this would be completed any time soon?

@waylan

waylan commented Apr 7, 2021

Copy link
Copy Markdown
Contributor Author

@tomchristie can we upgrade the Google Analytics account as discussed above?

If not, then we will need to work out some other solution to avoid the tests failing for the build of our own documentation.

@lovelydinosaur

Copy link
Copy Markdown
Collaborator

Right okay, this got buried. I'll put it on my TODO.

@waylan

waylan commented Jun 1, 2021

Copy link
Copy Markdown
Contributor Author

@tomchristie sorry to pester you but this is the only issue blocking the next release. If we are not going to get this update, we need to know so that we can plan around it.

@lovelydinosaur

lovelydinosaur commented Jun 2, 2021 •

Copy link
Copy Markdown
Collaborator

The UI is a bit inscrutable, but.... is this what you need?

Screenshot 2021-06-02 at 10 33 20

Failing that we could also perfectly well just drop the GA from the MkDocs site.

@waylan

waylan commented Jun 2, 2021

Copy link
Copy Markdown
Contributor Author

Yes, that resolves it. Thank you.

@waylan
waylan merged commit 80feaf0 into mkdocs:master Jun 2, 2021
@waylan
waylan deleted the gtag branch June 2, 2021 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google Analytics v4 (gtag)

4 participants