Pagespeed insights is a popular tool for many SEOs and web developers. Using the Lighthouse tool, its one of the best resources available for identifying and fixing speed issues to improve user experience. However, manually checking each URL via the website is a slow and manual process. Therefore, I have created a script to check the Core Web Vitals for a large number of URLs in bulk using the Pagespeed Insights API. No coding knowledge is required!
What are Core Web Vitals?
Core Web Vitals are a set of metrics which Google use to measure the user experience of a web page based on speed and performance. At some point in 2021, Google will officially use Core Web Vitals as a ranking factor. Currently, these are split into 3 aspects:
- Largest Contentful Paint (LCP) – How quickly the visibile part of the page loads
- First Input Delay (FID) – How quickly can the browser respond when interacting with a clickable element
- Cumulative Layout Shift (CLS) – How much the elements page moves around during page loading
Monitoring these metrics is important to providing a positive user experience. To do so in bulk for a number of URLs, just follow these simple steps:
Step 1 – Get API Key
To enable the script to work for large numbers of URLs, obtaining an API key is recommended. This is a unique identifier, which can easily be pasted into the script to authenticate requests made to the Pagespeed Insights Tool.
To obtain an API Key, just visit this page and then click on “Get a Key”.
Step 2 – Copy this script
Just open this script and save a copy.
It won’t work until you set up the API key. To do this, just replace the text “INSERT API KEY HERE” with your unique API Key identifier. Once done, you’re good to go!
Step 3 – Upload URLs
Before running the script, you will need to save your list of URLs to test in a CSV format, with just one column and no header. Once set up, just run the script by pressing CTRL+ENTER and wait for it to download the results.
Please note that this may take a while as you will need to wait for the Pagespeed Insights API to run for each individual URL. Just start the script and get on with your usual tasks whilst waiting for it to complete.
Field Data Vs. Lab Data
Pagespeed Insights reports two sets of results; field data and lab data. Field data uses results from real world usage from Google Chrome over the last two weeks and is a more accurate overview on how users experience the site. Lab data is based on live results from Google’s servers whilst running the test. Lab data is preferred for analysing pagespeed because improvements can be more directly observed.
For this script, Largest Contentful Paint and Cumulative Layout Shift will be reported from lab data. However, First Input Delay is based on field data as it is not reported in lab data.
Stay tuned, there’s more to come
Currently, this script only reports on the primary Core Web Vitals metrics. Future versions will include report on the opportunities for speed improvements to allow for bulk analyse pages in greater depth so stay tuned!
Enjoy this script? Why not try this script to scrape Google Trends.