FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Google Analytics v4 (gtag) · Issue #2252 · mkdocs/mkdocs · GitHub

/ mkdocs Public

Google Analytics v4 (gtag) #2252

Description

Google recently introduces Analytics v4.

ga4 no longer provides IDs compatible with analytics.js which are in the format UA-#####-#

ga4 now uses a new gtag.js and IDs in the format G-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 a G-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

google_analytics:
  - UA-#####
  - auto

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

gtag:
  - G-ABC123

options to mkdocs.yml that would use the new gtag.js which is documented by google to be implemented as

<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABC123"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() {
        dataLayer.push(arguments);
    }
    gtag('js', new Date());
    gtag('config', 'G-ABC123');
</script>

This would allow existing mkdocs users to continue using google_analytics: for as long as google continues to support it, or upgrade to gtag: 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementTheme-generalIssues involving the theme related code within MkDocs

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL