Automate Google PageSpeed Insights and Core Web Vitals Logging with Apps Script

By Robert Ellison. Updated on Friday, September 30, 2022.

Upload

Here's a quick script to automatically monitor your Google PageSpeed Insights desktop and mobile scores for a web page, together with core web vitals (LCP, FID and CLS):

You need a spreadsheet with a tab called results and an API key for PageSpeed Insights (activate the API in the console and create an API key for it, the browser based / JavaScript option). Paste the code above into the script editor for the spreadsheet and add your API key and URL to monitor. Then just choose triggers from the Resources menu and schedule the monitor function to run once per day.

The script will log the overall PageSpeed score out of 100 for the monitored page. It also logs 75th percentile origin level core web vitals (largest contentful paint (LCP, seconds), first input delay (FID, seconds) and cumulative layout shift (CLS, percent)). If your origin does not have enough data the metric will be omitted. You can change from origin to page level web vitals if you have enough data, just change originLoadingExperience to loadingExperience in the script.

The results are repeated for desktop and mobile, so your spreadsheet header should be Desktop PSI, Desktop LCP, Desktop FID, Desktop CLS, Mobile PSI, Mobile LCP, Mobile FID, Mobile CLS.

There are a lot of other values returned (like number and types of resources on the page) that you could choose to monitor as well. It would also be easy to extend this to monitor more URLs, or to send you an email if the score drops below a threshold.

Updated May 5, 2019 to use version 5 of the PageSpeed API.

Updated June 13, 2021 to include core web vitals.

Add your comment...

More Google Apps Script Projects

(All Code Posts)

(Published to the Fediverse as: Automate Google PageSpeed Insights and Core Web Vitals Logging with Apps Script #code #google #appsscript #gas #pagespeed How to automatically monitor page load performance using the Google PageSpeed Insights API and Apps Script )

Prior Artist

By Robert Ellison. Updated on Sunday, October 23, 2022.

Golden Gate Park from Grand View Park

By Robert Ellison. Updated on Saturday, January 18, 2025.

Golden Gate Park from Grand View Park

Panoramic photo of the full extent of Golden Gate Park as seen from Grand View Park in San Francisco.

This photograph presents a sweeping panorama of Golden Gate Park captured from the elevated Grand View Park. A sea of densely packed rooftops covers the bottom half of the image, varying in subtle shades of whites, grays, and browns, conveying the bustling urban environment. This mosaic of human habitation stretches out towards the dark green swath of Golden Gate Park, which creates a natural ribbon through the cityscape. Above, a heavy, low-lying fog blankets the sky, merging almost seamlessly with the distant horizon. The muted tones evoke a serene, albeit misty mood, enveloping the landscape with an ethereal quietness that San Francisco is known for. The cityscape feels like an almost living organism, caught in a slow breath beneath its foggy cover.

In terms of composition, the panoramic style is well-suited for capturing the expansive scope of the scene. The horizontal lines dominate the image, guiding the viewer’s eye from one end of the city to the other, instilling a sense of vastness. The contrast between the dense foreground and the soft, foggy background adds depth, while the park acts as a central line of calm amidst the urban chaos. However, the uniformity in color tones, largely dictated by the fog, results in a somewhat flat appearance, lacking vibrant contrasts that might otherwise enhance visual interest. While the mood is effectively captured, the photograph could benefit from a bit more color differentiation, perhaps capturing a break in the clouds or a sliver of sunlight filtering through, to add dynamism to an otherwise subdued palette.

Add your comment...

Related Posts

(Recent Photos)

(Published to the Fediverse as: Golden Gate Park from Grand View Park #photo #grandview #goldengatepark #sanfrancisco Photo (Panoramic) of Golden Gate Park from Grand View Park in San Francisco, California. )

New Scientist on Immigration

New Scientist on Immigration

The April 6 issue of New Scientist has a special focus on immigration. All worth a read, but here's an assessment of the horrible cost:

"A meta-analysis of several independent mathematical models suggests it would increase world GDP by between 50 and 150 per cent. “There appear to be trillion-dollar bills on the sidewalk” if we lift restrictions on emigration, says Michael Clemens at the Center for Global Development, a think tank in Washington DC, who did the research."

And the uncontrollable hordes:

"Niger is next to Nigeria, Nigeria is six times richer and there are no border controls, but Niger is not depopulated. Sweden is six times richer than Romania, the EU permits free movement, but Romania is not depopulated."

Time for open immigration?

Add your comment...

Related Posts

(All Politics Posts)

(Published to the Fediverse as: New Scientist on Immigration #politics #immigration New Scientist points out that immigration raises GDP and does not depopulate poorer countries, so let's have more of it. )

The real reason Americans don't have passports

By Robert Ellison. Updated on Sunday, November 5, 2023.

The real reason Americans don't have passports

Less than half of Americans have passports compared to around 75% in the UK. Brits often use this statistic to mock Americans for being uncurious provincial stay-at-homes.

I've always felt this was unfair though. As an American you might have visited all 50 states, all of the National Parks and maybe thrown in Canada, Mexico and Puerto Rico without having ever bothered with a fully fledged passport.

A Brit on the other hand might have spent a few days eating fish and chips at a British pub in Benidorm and is suddenly a sophisticated world traveler. I don't think so. There is simply more to see and experience in the US without needing to cross a border.

After I moved to America I realized that maybe there was another reason. Americans for some reason don't bother taking vacations. You get massively less vacation time over here and even then a huge number of people don't even manage to take off their paltry few days. There is no effective way to have a holiday overseas if you never take a holiday.

Now I realize that neither of these factors is as important as the United States Postal Service if you have a kid.

In the UK to get a passport you mail in an application and get back a passport. It's pretty easy. Even for children.

In the US you need to go to a Passport Acceptance Facility and that probably means a post office. There is a handy website that lists the 10 closest facilities together with their phone numbers so you can call to make an appointment. These phone numbers are not answered. It's less like a basic government service and more like trying to bag a ticket to Glastonbury.

I gave up and delegated to Fancy Hands (a personal assistant service). They have spent two days on the phone trying and failing to get an appointment.

I was going to do my best to vote my principles this year but at this point any presidential candidate who would force USPS to put in a web scheduling system might just get my vote.

Updated 2016-04-18 23:23:

After I posted this a friend pointed me at the United States Digital Service (via this Ted Video) and basically said why bitch and moan when you could help fix it. Which I don't have a great answer to. Except this.

Add your comment...

Related Posts

(All Etc Posts)

(Published to the Fediverse as: The real reason Americans don't have passports #etc #passport #travel #usps Americans don't get enough vacation and have plenty to see at home, but the real reason they don't have passports is the United States Postal Service )

Clouds Over The Farallones

By Robert Ellison. Updated on Saturday, January 18, 2025.

Clouds Over The Farallones

Dramatic clouds over the Farallon Islands in the Pacific just off San Francisco.

The photograph, titled "Clouds Over The Farallones," captures a dramatic sky where thick, brooding clouds loom ominously over a tranquil sea. The sun struggles to pierce through the dense layers, resulting in ethereal beams of light that dance on the surface of the water. The horizon is obscured, giving the scene an infinite feel, as if the ocean stretches beyond the visible world. The overall atmosphere is one of serene majesty, where light and shadow engage in a quiet, ongoing battle, casting the scene in a muted palette of grays and silvers.

The composition adheres to the principles of balance and contrast, with the turbulent sky occupying the upper half of the frame juxtaposed against the calm, reflective sea below. The photographer effectively employs chiaroscuro—an interplay of light and dark—to convey depth and mood. The choice to capture the scene in a subdued color scheme enhances the emotional weight, evoking contemplation and introspection. However, while the minimalism is powerful, the absence of any distinct focal point could lead to a sense of vagueness. Some viewers might find this lack of a singular subject slightly detracting, although it also adds to the photograph's dreamlike quality. Overall, it is a compelling blend of nature’s elements, harmoniously captured.

Add your comment...

Related Posts

(Recent Photos)

(Published to the Fediverse as: Clouds Over The Farallones #photo #farallones #farallon #sanfrancisco Photo of some dramatic clouds over the Farallon Islands in the Pacific Ocean near San Francisco, California. )

Book reviews for March 2016

By Robert Ellison. Updated on Friday, February 24, 2017.
The Girl on the Train by Paula Hawkins

The Girl on the Train by Paula Hawkins

2/5

I found it hard to care for anyone in this book. Pedestrian mystery.

 

Half Way Home by Hugh Howey

Half Way Home by Hugh Howey

3/5

Getting into diminishing returns here. Good, but not Silo/Sand good.

 

Beacon 23: The Complete Novel (Beacon 23 #1-5) by Hugh Howey

Beacon 23: The Complete Novel (Beacon 23 #1-5) by Hugh Howey

3/5

 

Add your comment...

Related Posts

(All Reviews)

West Portal Mosaic Timelapse

By Robert Ellison. Updated on Saturday, February 19, 2022.

West Portal Mosaic Timelapse

A mosaic timelapse looking over the Pacific from West Portal, San Francisco (a simultaneous timelapse of 225 days from mid 2015 to early 2016).

This is the second in a series of videos made from frames I captured from a Nest cam using  Google Apps Script. Music from JukeDeck.

(Previously)

Add your comment...

Related Posts

(More Timelapses)

(Published to the Fediverse as: West Portal Mosaic Timelapse #timelapse #westportal #mosaic #video Mosaic timelapse made from 225 days of footage from West Portal, San Francisco looking out over the Pacific. )

Google Cloud Vision Sightings

Google Cloud Vision Sightings

I've been feeding webcam images into the Google Cloud Vision API for a few weeks now so I thought I'd take a look at what it thinks it can see. The image above shows every label returned from the API with my confidence going from the bottom to the top and Google's confidence going from left to right (so the top right hand corner contains labels that we both agree on).

Google is super-confident that it has seen a location. Can't really argue with it there.

It's more confident that it has seen an ice hotel than a sunrise (and it has seen a lot of sunrises at this point). Maybe I need to explore the Outer Sunset more.

Google is 60.96% confident that it has seen a ballistic missile submarine. I suppose that's plausible, I do have an ocean view but it's rather far away and unless there was an emergency blow that didn't make the news I'm going to have to call bullshit on that one. It's 72.66% confident that an Aston Martin DB9 went past which is pretty specific. Possibly a helicopter slung delivery?

Maybe I'm sending basically the same image in too many times and the poor system is going quietly mad and throwing out increasingly desperate guesses. Probably I've just learned that I should use 80%+ as my confidence threshold before triggering an email...

(Previously)

Add your comment...

Related Posts

(All Etc Posts)

(Published to the Fediverse as: Google Cloud Vision Sightings #etc #google #vision Things that Google Cloud Vision claims to have seen from my San Francisco web cam (including an ice hotel and a ballistic missile submarine), )

Vernal Equinox 2016

Vernal Equinox 2016

It's the start of Spring, unless you're equatorially challenged in which case welcome to Autumn.

Rendered in Catfood Earth (Windows, Android).

(Previously, Previously)

Add your comment...

Related Posts

(All Code Posts)

(Published to the Fediverse as: Vernal Equinox 2016 #code #earth #equinox #spring #autumn #vernal The exact moment of Vernal Equinox 2016 as rendered in Catfood Earth. )