CRUX API throws error when I want to get loading experience data(LCP,CLS,FID) of a URL that have a redirection(301)

98 Views Asked by At

I want to use CRUX API to get URL based loading experience data(LCP, CLS, FID). If the URL have a redirection due to something missing in cookie, CRUX API returns error. But CRUX API querying with URL from BigQuery, it should not be important that the URL have redirection or not. CRUX API also returns lighthouse result. In this case, redirection can be matter. But it can't be related with origin loading experience(LCP, CLS, FID).

Same problem happened in the https://pagespeed.web.dev/ when I want to get RUM data for a URL.

It shows results for redirected URL instead of original one.

How can I get these results for redirected URLs?

I tried to get loading experience data of a URL that have a redirection from CRUX API but it throws an error. I expected to get data without an error because URLs in the CRUX Big Query does not related the URLs have redirection or not.

1

There are 1 best solutions below

0
Barry Pollard On

Redirects are not handled by the CrUX API:

Complex actions like following redirects are not handled.

CrUX is intended to show the page experience of the provided URL. For a URL with a redirect this can result in a very different page. For example if you ask for CrUX data for https://www.example.com/account/ and it redirects you to https://www.example.com/loggedin-page/login/ then those two pages may have very different experiences. To return the results of one, when the other is requested, could be quite confusing.

How can I get these results for redirected URLs?

Follow the redirect before submitting it to the CrUX API.

I expected to get data without an error because URLs in the CRUX Big Query does not related the URLs have redirection or not.

I do not understand your questions about the CrUX Big Query dataset. This only returns origin-level data, and does not have any URL-level data.