GoogleChrome / CrUX

The place to share queries, ideas, or issues related to the Chrome UX Report
https://developers.google.com/web/tools/chrome-user-experience-report/
Apache License 2.0
207 stars 47 forks source link

HUGE Discrepancies CrUX vs web-vitals.js+Google Analytics+BigQuery: LCP: 300% - FID: 15% - CLS: 3500% #15

Closed headerbidding closed 1 year ago

headerbidding commented 1 year ago

I am a one-man website owner and only found out about Core Web Vitals a few months ago. I was shocked when I saw that Google considers none of my pages proving a good user experience, so I went to work improving all aspects of my site. While I was able to make all my pages mobile friendly, I had very little success improving LCP and CLS After 2 months of studies, experiments and improvements, my site is all “green” in lab tests and RUM tests (including my own web-vitals sent to GA4 and analyzed with BigQuery), but still in “RED” as far as Google is concerned. I am at the end of my wits now.

Please look at my detailed screenshots below:

Edit: core-web-vitals-discrepancies-images-new.pdf

My most visited (and also worst performing) page is: https://www.flixxy.com/trumpet-solo-melissa-venema.htm

Notes: I understand the differences between Lab test Field tests and RUM. I also looked in detail into the differences between CrUX and RUM (per: https://web.dev/crux-and-rum-differences )

1) CrUX is Chrome only: Even if I filter GA4 for Chrome users only, the differences persist. 2) Opted-in users: This should only account for a small difference. 3) Website must be publicly discoverable: My site is 100% public 4) CrUX segments data by mobile, desktop, and tablet: The differences persist if I segments data by mobile, desktop, and tablet. 5) Sampling size: I am using a sampling size of over 30,000 sessions 6) Timespan: I am analyzing over 28 days of GA data. 7) CrUX metrics are measured at the 75th percentile: Core Web Vitals with GA-4 and BigQuery measures data at 75p. 8) Metrics timing a) LCP: I am using the Google recommended Core Web Vitals javascript. b) "CLS is measured through the life of the page": Visual inspection as well as Chrome Dev Tools show no significant CLS (>0.01). Neither does GA4. How come CrUX sees 0.35 CLS? 9) CrUX does measure metrics within iframes, Core Web Vitals javascript does not :
All my iframes are wrapped with div's defined in width and height and overflow: hidden to avoid any CLS 10) Cross-origin resources: “LCP media served from other domains do not give render time in the PerformanceObserver API—unless the Timing-Allow-Origin header (TAO) is provided.” I noticed this one only just now and have now added a TAO to my .htaccess file.
11) Background tabs and prerender: I do not use Background tabs and prerender.

Final questions:

Hugh

www.flixxy.com

tunetheweb commented 1 year ago

Hi Hugh,

It seems like you've done a lot of work to try to improve this and I can really appreciate how frustrating it must be after all that effort to be no further forward.

The good news is that this is explainable. The bad news is you may not like the explanation, and the fix is tougher 😔

First, let's correct a couple of assumptions here:

Cross-origin resources: “LCP media served from other domains do not give render time in the PerformanceObserver API—unless the Timing-Allow-Origin header (TAO) is provided.” I noticed this one only just now and have now added a TAO to my .htaccess file.

You cannot fix this within your .htaccess file as the header needs to be sent on the domain sending the image. If it's the same origin it doesn't need the header, if it's a different origin you likely won't have access to add this (the one exception is if you are in control of the other domain - say it's an asset domain like assets.example.com that you serve images from).

However, TAO isn't the main problem here, so let's move into the tricker issue:

CrUX does measure metrics within iframes, Core Web Vitals javascript does not : All my iframes are wrapped with div's defined in width and height and overflow: hidden to avoid any CLS

The problem isn't that the iframe itself may move - it's that content within the iframe may shift. Causing CLS.

Web APIs (as used by web-vitals.js and other tools) cannot "see" into iframes. This is a fundamental security restriction for the web platform.

This is noted in the documentation your referenced, and also in the Limitations section of the web-vitals repo:

The primary limitation of these APIs is they have no visibility into