PageSpeed Insights with a Google key
Cora can run Google’s PageSpeed Insights on any public page and tell you how fast it is, its Core Web Vitals and what to fix first. She needs a Google API key for it, which you keep in the mission’s vault. She never sees the key. This page uses an invented company, Kestrel Cycles, and its web lead, Leah Thompson.
1. Make a key that can only run PageSpeed Insights
Section titled “1. Make a key that can only run PageSpeed Insights”- Sign in to the Google Cloud console.
- Open APIs & Services, then Library. Search for PageSpeed Insights API and press Enable.
- Open APIs & Services, then Credentials. Press Create credentials, then API key. Copy the key.
- Press Edit API key (or open the key from the list). Under API restrictions choose Restrict key, tick only PageSpeed Insights API, and press Save.
A key restricted this way can run page speed tests and nothing else in your Google account. The PageSpeed Insights API is free within Google’s daily quota.
2. Add it to the mission’s vault
Section titled “2. Add it to the mission’s vault”You need to be a mission admin (or an org admin in the mission).
- Open the mission and press the Details button at the top right.
- Choose the Tools tab, go to Vault keys, press Add a key and fill in the form:
- Name:
PAGESPEED_KEY - Value: paste the key.
- Note: “Google key, PageSpeed Insights only”.
- Allowed hosts:
www.googleapis.com - Access: Ask first (the default) or Allowed.
- Name:
- Press Add key. The form closes, and the key can never be shown again.
With Ask first, each report waits for a mission admin to approve it on a card in the mission. Choose Allowed if you want reports to run without asking: this key can only run page speed tests, so that is usually fine.
If you ask Cora for a report before the key is there, she posts a card asking for it. As a mission admin, press Add it in the Vault on the card and the form opens ready with the name and host.
3. Ask Cora for a report
Section titled “3. Ask Cora for a report”Write to Cora in the mission, for example:
- “@Cora run PageSpeed on https://kestrelcycles.example/ for mobile.”
- “@Cora check the speed of our booking page on mobile and desktop, and give me the top three fixes.”
Cora tests mobile unless you ask for desktop (or both), with the performance, accessibility, best practices and SEO scores. A test takes Google 10 to 60 seconds. She saves Google’s full answer in the team sandbox, summarises it with a small script, and reports:
- the four category scores, out of 100;
- the Core Web Vitals from Google’s lab test (Largest Contentful Paint, Cumulative Layout Shift, Total Blocking Time, and the rest);
- field data from real Chrome users, where Google has it for the page or the site. Many pages have none, and Google has said it will stop including it in this API, so it may be missing;
- the top opportunities, with the time each could save.
A page that needs a sign-in, or that blocks Google, cannot be tested; Cora says so.
Good to know
Section titled “Good to know”- The key is sent only to
www.googleapis.com, and only by the platform, never from Cora’s sandbox. See The mission vault. - When this mission is a hero and another mission calls it in for a report, the hero saves Google’s answer and runs the summary in its private folder for the call, not the team folder, and puts the numbers in its answer (D0805).
- To stop reports, set the secret’s access to Off or remove it. To change the key, use Replace value.
- If the key is ever pasted in the chat, delete it in Google and make a new one.