Import GTmetrix Data to Google Sheets

In this guide, we’ll walk through how to pull data from the GTmetrix API directly into Google Sheets, using the API Connector add-on for Sheets.


Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Get Your GTmetrix API Key

  1. If you haven't already, create an account at and log in
  2. Click Account from the dropdown Account menu at the top (or navigate directly to
  3. On the account page, scroll down and click Generate API Key
  4. Your key will now be displayed. Copy this to your clipboard as we'll use it right away.
  5. One last step: Because the GMetrix API requires Basic Authentication, we need to encode our API key to base 64. You can do this by entering your API key into this form.

    The encoding script runs in your browser, and none of your credentials are seen or stored by this site.


Part 2: Pull GTmetrix API Data into Sheets

GTmetrix uses a credit system, where different API reports require different numbers of credits. You can run a request to any of the endpoints shown in the documentation, but for this example, we'll fetch a Lighthouse page speed report, which costs 1 credit.

Substitute in your own encoded API key where it says your_encoded_key, and modify the request body as needed using the test parameters provided here.

  1. Open up Google Sheets and click Extensions > API Connector > Open > Create request.
  2. In the request form enter the following to set up the test:
    • ApplicationCustom
    • MethodPOST
    • Request URL
    • Headers:
      • Authorization: Basic your_encoded_key
      • Content-Type: application/vnd.api+json
    • Request body: {"data":{"type":"test","attributes":{"url":"","location":"1","browser":"3","adblock":1,"report":"lighthouse"}}}
  3. Create a new tab and click Set current to use that tab as your data destination.
  4. Name your request and click Run. A moment later you’ll see response metadata and the report status populate your sheet. This means the report is now in the queue waiting to be run.
  5. Pay special attention to the value in the links.self field as this is the link to the finalized report. We'll create a new request that plugs this URL into the request URL field. Note that it may take a few minutes for this report to be ready.
    • ApplicationCustom
    • MethodGET
    • Request URL
    • Headers:
      • Authorization: Basic your_encoded_key
  6. You should now see your Lightspeed report results.
  7. To automate this further, you may want to reference the cell containing the links.self URL, instead of entering it directly. This is convenient as it allows you to dynamically fetch new data without manually updating your request.

Part 3: API Documentation

Official API documentation:

Location IDs
1TRUENorth AmericaVancouver, Canada
2TRUEEuropeLondon, UK
3TRUEAsia PacificSydney, Australia
4TRUENorth AmericaSan Antonio, TX, USA
5TRUEAsia PacificMumbai, India
6TRUELatin AmericaSão Paulo, Brazil
7TRUEAsia PacificHong Kong, China
8FALSENorth AmericaQuebec City, Canada
9FALSENorth AmericaSan Francisco, CA, USA
10FALSENorth AmericaCheyenne, WY, USA
11FALSENorth AmericaChicago, IL, USA
12FALSENorth AmericaDanville, VA, USA
13FALSEEuropeAmsterdam, Netherlands
14FALSEEuropeParis, France
15FALSEEuropeFrankfurt, Germany
16FALSEEuropeStockholm, Sweden
17FALSEAsia PacificSingapore
18FALSEAsia PacificTokyo, Japan
19FALSEAsia PacificBusan, South Korea
20FALSEAsia PacificChennai, India
21FALSEAfricaJohannesburg, South Africa
22FALSEMiddle EastDubai, UAE
Browser IDs
3chromeChrome (Desktop)
1firefoxFirefox (Desktop)

2 thoughts on “Import GTmetrix Data to Google Sheets”

  1. Thank you very much. This was great, well explained, it worked very well.

    I'm now trying to optimize my spreadsheet referencing cells and keeping a data history of each API run.

    Unfortunately I can't find a way I could run your addon a second time appending a new row and referencing it dinamicly for each new future run.

    And I couldn't find a way to automaticly download the PDF report.

    • Hey Rafael, if I've understood what you're saying correctly, I believe you could use the following process:
      1) Day 1: Run the test setup request using the endpoint
      2) Day 1: Fetch the results using the!A1+++ endpoint, referencing the cell containing links.self. Tick the "Add timestamp" option so you can track when it ran (under Output options).
      3) Day 2: Run the test setup request again
      4) Day 2: Run the data fetch request again, but this time edit (and save) it to run in Append mode. Now the results and timestamp will print out underneath the first test results.
      5) Day 3 and on as the same as Day 2. Basically only the initial run should be in Overwrite mode, following that all requests should run in Append mode.

      API Connector doesn't have any PDF download functionality, but let me know if that answers your question about appending data.


Leave a Comment

Jump To