-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Update Google Analytics to gtag #1972
Comments
I just responded to a similar issue on the Hugo repo a few days ago. :-) Basically, switching to One of the other reasons I preferred the I realise that Google are starting to push gtag more, so maybe they will discontinue the analytics.js implementation in the future, but as of right now it is still supported and I think a more efficient way of tracking analytics. I don't mind if @squidfunk wants to switch the implementation to gtag now though - it doesn't really make a big difference performance wise and they both load async. |
@coliff thanks for the quick analysis! 262% is quite a number. We won't switch until this number goes way down or Additionally, introducing
Thus, it makes no sense to switch the default integration at this moment. Closing. |
Just for fun I did some testing. In my testing:
Not overly scientific. I just loaded and reloaded the page a few times with each version of the code and randomly stopped reloading and copied the results. I didn't record or average results. Just wanted to see after reloading (letting cache kick in) how it would perform. I can absolutely see the difference in size and the extra few requests with the new code, but looking at the big picture the new code is roughly 1/10th of a second slower to load and around 200kB bigger (although a direct comparison of the file sizes of the individual js files doesn't reflect exactly the difference in what is loaded by the browser: I agree with what seems to be a removed comment someone else made that I am copying from the email notification and reposting:
Personally I don't care about both being offered. I imagine anyone who wants to enable Google Analytics is looking to do so by using the code Google provides/recommends. I would think that with Google sending out nag emails for people to switch that it makes more sense to include the new code and provide the template override instructions to anyone who comes asking "how do I switch back". I imagine the number of people who come asking that would probably be less than the number coming to mention they are getting nag emails. 🤷 That's just my 2c though. |
First, thanks for taking the time to investigate. Actual measuring is always better than guessing, and I'm a huge fan of generating some data to come to an informed decision. Here's the data you generated again side-by-side for better comparison:
Most numbers have increased by a significant amount. DOMContentLoaded dropped, which seems counter-intuitive given that all other times increased - might be a measuring error.
It seems you measured without setting network conditions (i.e., throttling). It's always good to measure using "Fast 3G" and "Slow 3G" to estimate how the site behaves on slower mobile connections (e.g., in emerging markets or Germany - the mobile Internet sucks here!). I'd guess that Load and Finish times will be way, way higher on slower connections if you measure with network throttling. An increase of 200 kB is extremely substantial. With the release of 6.0.1, I was able to decrease the overall JavaScript payload of Material from 176 kB to 124 kB (see this tweet for a detailed explanation) – so the whole of Material for MkDocs weighs 124 kB. This includes the RxJS code, ClipboardJS, a ResizeObserver polyfill, etc. Adding 200 kB, which would be 160% of the theme's payload, seems not a good idea to me. If I've learned one thing from the last 4 1/2 years maintaining this project, it's that people are very, very sensitive to changes. It's very hard to estimate what will trip up the users. A change of this magnitude for literally no upside, only downsides through increased load times and worse Lighthouse benchmarks (another thing people are taking very seriously) doesn't sound great to me.
I was also wondering about the removed comment. I also got that email. Yes, Google's advice is to use
I care about both being offered because I'm the one who has to maintain it after all. Google Analytics is only integrated natively because MkDocs offered it from version 0.x as part of the
You're the first one. I'm running Google Analytics on some sites and haven't noticed so far. |
@squidfunk sorry to necro this, but I am attempting to help a friend setup an mkdocs deployment with google analytics and it appears he is not able to setup anything except Google Analytics V4 which no longer provides a UA-##### and instead seems to require the use of gtags. since new GA users are forced to GA4 and existing users (myself included) are being sent emails from google urging them to upgrade it's probably a good idea to reconsider this. P.S. I upgraded one of my less important GA properties to GA4 and it no longer has a UA-##### and now only has the option to use gtags, which seem to give a measurement ID in the format G-ABC123. |
For those who find this, I've opened an issue upstream mkdocs/mkdocs#2252 requesting support for ga4 in mkdocs. |
Google Analytics extra:
analytics:
provider: google
property: UA-XXXXXXXX-X Google Analytics 4 (via extra:
analytics:
provider: google
property: G-XXXXXXXXXX |
I checked that...
Description
Google has been sending me emails that
analytics.js
is being replaced bygtag.js
and has a new code snip to use it.Possibly related (although I think they are talking about a different feature, unless Google combined these): #1914
Use Cases
Anyone receiving the emails to update would stop receiving the emails 😄
Apparently Google lists the selling points as:
Screenshots / Mockups
The text was updated successfully, but these errors were encountered: