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

new_audit: Don't load gtag.js if all you use is google analtyics #10783

Open
paulirish opened this issue May 14, 2020 · 7 comments
Open

new_audit: Don't load gtag.js if all you use is google analtyics #10783

paulirish opened this issue May 14, 2020 · 7 comments

Comments

@paulirish
Copy link
Member

paulirish commented May 14, 2020

Provide a basic description of the audit

As of late 2017, the copypaste tracking code GA gives you is for gtag.js, not the old (i,s,o,g,r,a,m) analytics.js code. But gtag.js just loads analytics.js, making it pretty useless.

More context from @philipwalton: googleanalytics/autotrack#202 (comment)
And also here: philipwalton/analyticsjs-boilerplate#19 (comment)

There are some benefits to using gtag if you're doing other things beyond analytics, so perhaps we can give those cases a pass. But if all someone wants is GA, then they should use that.

The idea is to detect when a page uses gtag.js and then it loads analytics.js and nothing else. And then recommend they swap it for the GA tag directly.

image
image (7)

More

How would the audit appear in the report?

wording tbd but perhaps:

Failing: Reduce gtag overhead on Google Analytics tag request
Passing: Google Analytics tag included efficiently

For UI in Failing case maybe we use the CRC renderer to show the two requests chained.

How is this audit different from existing ones?

None cover this.

What % of developers/pages will this impact?

gtag.js is probably on 80% of the sites that added google analytics in the past 3 years.
this solo-GA case is probably... 40% of them.

So.. ~30% of sites that have added GA in the past 3 years. That's a few.

How is the new audit making a better web for end users?

Less bytes downloaded. 84k/34k gzip'd. Less JS run.

What is the resourcing situation?

Core team

Any other links or documentation that we should check out?

@dthree
Copy link

dthree commented Mar 16, 2021

@paulirish love if this could be added, GA gives us one of the biggest dings on our sites as we are optimizing for perf. Our use case for GA is very minimal. Any new news on this?

@Eyas
Copy link

Eyas commented Aug 20, 2021

What's Lighthouse's take on gtag.js, especially now that GA4 is out and seems to be incompatible with the old analytics tracking script?

Lighthouse still complains about tons of unused code in gtag.js, but unlike the previous state a ~year ago, there is no recourse for someone using GA4.

@pereorga
Copy link

Should this issue be renamed to: "new_audit: Consider removing Google Analytics / gtag.js and switch to less-heavy alternatives" ?

In GA4, people who only want simple stats for their website are now forced to use gtag.js, and this is less than ideal IMHO

@adriaandotcom
Copy link

adriaandotcom commented Jul 12, 2022

I did a test in the past on Google Analytics with Simple Analytics:

https://blog.simpleanalytics.com/google-penalizes-you-for-using-google-analytics

This is the Lighthouse score:

Screenshot

Basically, you see that having Google Analytics costs you almost 10 percentage points, and with Simple Analytics only 0.2 percentage points.

@OliverJAsh
Copy link

OliverJAsh commented Feb 17, 2023

Universal Analytics (UA) is being deprecated, meaning we have to switch to GA4 and we have no choice but to use gtag.js (analytics.js doesn't work with GA4 as far as I understand—please confirm).

The old analytics.js tag was ~20 KB gzipped. The new gtag.js tag is ~80 KB gzipped. 😞

@Waazer
Copy link

Waazer commented Feb 17, 2023

Waaaaaaat boooooool

@adamraine adamraine added P2 and removed P1.5 labels Sep 25, 2023
@pereorga
Copy link

pereorga commented Dec 7, 2023

I fail to see why this is still open, at least with the current title and description. The recommendation to use GA directly is outdated and counterproductive. As of today, websites that did not update to GA4 are downloading both files (~20 KB gzipped + ~80 KB gzipped).

By the way, these outdated websites can still get 100% score (performance/SEO/best practices) on Lighthouse, for example see https://dsff.uab.cat/. Maybe the new audit should check that, instead? It would consist of checking the opposite of what the original issue was describing, though.

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