Track page speed with Google PageSpeed Insights API

Hey people,

Do you need to track page speed of your website, or of several landing pages? Would you like to get email alerts if a page is too slow. Let’s do that with dashdash! :muscle: :rocket:

The app looks like this:

We are using the Google Pagespeed Insights API for this. You will need a Google API key. There are alternative services like pingdom that you can use. Once you have an API key, go ahead and activate the Google Pagespeed integration in our Integrations menu.

We will do the following steps:

  1. Set up automation
  2. Send requests
  3. Parse score
  4. Insert into log

1. Set up automation

B1: 0 or 1 - this is just a manual switch
B2: =IF(C1=1,REPEAT(TODAY(),1440),"-- stopped --")

So if you set the switch in C1 to 1, you will have TODAY’s date repeated daily.

2. Send requests

A5: [the URL you want to track] - note that the API requires to send http(s)://…
B5: =IF($B$2>1,PAGESPEED_GOOGLE(A5))
C5: =IF($B$2>1,PAGESPEED_GOOGLE(A5,"mobile"))

We send two different requests here. As you can see, we add the strategy “mobile” in C5, while the request in B5 uses the default strategy for “desktop”.

3. Parse score

D5: =PARSE(B5,"['ruleGroups'].['SPEED'].['score']")
E5: =PARSE(C5,"['ruleGroups'].['SPEED'].['score']")

Now we grab the pagespeed score for both desktop and mobile. Note that there are many other metrics you can parse from the JSONs in columns B and C. Check for example the “pageStats” offered in the documentation.

4. Insert into log

F8: =IF($B$2>1,TODAY())
G8: =IF(F5<>FALSE,INSERT(A$4:F$4,A5:F5,'Log'!A$1:D$1),"-- stopped --")

Now we add a time stamp. And we insert the data into a separate Log view so we can analyze it later.

That’s it! Now if you want to send alerts, please check our posts about email and SMS.

Happy building! :raised_hands: :raised_hands:


If you don’t want to use our integration for the requests, you can use our GET function as an alternative. It works like this, assuming you store your API key in G1:

B5: =IF($C$2>1,GET("https://www.googleapis.com/pagespeedonline/v4/runPagespeed?url="&A8&"&strategy=desktop&key="&$G$1))
C5: =IF($C$2>1,GET("https://www.googleapis.com/pagespeedonline/v4/runPagespeed?url="&A8&"&strategy=mobile&key="&$G$1))

3 Likes

If you want a nice UI https://pagespeedplus.com can track your pagespeed insights scores and send notifications when it drops