-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
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 👍 |
Yea, the idea this would be part of 0.4, and then it can be removed in 0.5. |
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 ..
|
My current version is 4.12 ( as available in nixpkgs) |
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. |
Stephen @schungx 3- Thanks for the response . Could you please link me to the google script you mentioned above . |
This is how I have it in <!-- 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. |
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 thehead.hbs
extension provides a means to do so.Closes #1635