Skip to content
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

Deprecate google-analytics #1675

Merged
merged 1 commit into from
Nov 27, 2021
Merged

Deprecate google-analytics #1675

merged 1 commit into from
Nov 27, 2021

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Oct 24, 2021

This puts a deprecation notice for the output.html.google-analytics field, with the intent to remove it in the 0.5 release. The current code has been outdated for a while, and doesn't provide very much flexibility. I also prefer not to endorse any particular service, instead letting the user pick whichever they want. Placing the code in the <head> tag is the recommended approach, and the head.hbs extension provides a means to do so.

Closes #1635

@YJDoc2
Copy link
Contributor

YJDoc2 commented Oct 27, 2021

This seems good on its own, but would there be a minor release with this change in it? If this will be landing in 0.5.*, then this PR might as well remove it, as you have mentioned that the field will be removed in 0.5 release. Unless someone is depending on tip of master branch, they will still get version 0.4.* from crates io.

If there is a plan of releasing a 0.4.* release , then the deprecation makes sense, and in that case, the PR seems fine 👍

@ehuss
Copy link
Contributor Author

ehuss commented Oct 27, 2021

Yea, the idea this would be part of 0.4, and then it can be removed in 0.5.

@ashutoshmjain
Copy link

Quick question. - Do I need to be on a specific version of mdbook to be able to use GA4 ? Asking cuz I received this notice from google ..

Universal Analytics will no longer process new data in standard properties beginning July 1, 2023. Prepare now by setting up and switching over to a Google Analytics 4 property.

@ashutoshmjain
Copy link

My current version is 4.12 ( as available in nixpkgs)

@schungx
Copy link

schungx commented Mar 25, 2022

If you use the new script snippet from Google, it'd work both for GA4 as well as the old UA accounts.

However, beware - GA4 is missing a LOT of functionalities, especially filters. So you may actually want to send simultaneously to both accounts for a while.

@ashutoshmjain
Copy link

Stephen @schungx 3- Thanks for the response . Could you please link me to the google script you mentioned above .

@schungx
Copy link

schungx commented Apr 1, 2022

This is how I have it in theme/head.hbs

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
    var localAddrs = ["localhost", "127.0.0.1", ""];

    // Make sure we don't activate Google Analytics if the developer is inspecting the book locally...
    if (localAddrs.indexOf(document.location.hostname) === -1) {
        window.dataLayer = window.dataLayer || [];
        function gtag() { dataLayer.push(arguments); }
        gtag('js', new Date());

        gtag('config', 'G-XXXXXXXXX');
    }
</script>

You need to create a new GA4 property, otherwise your UA properties will deprecate in a year or so.

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 only work with old Universal Analytics tag propery id
4 participants