The Google Spreadsheet API Connector allows to import Tests list as well as Export their Results to Google Spreadsheet files via the Google Sheets API.
SERVICE_ACCOUNT_CREDENTIALS
- The path to the Service Account json file.
In order to use the Google Sheets API via npm you need to complete these steps:
-
Create a new or use an existing Google Service Account.
-
Create a new or existing Google Sheets file and share it with the Google Service Account email address with Editor permissions (Example template available here)
- This file should have Tab names useful to either fetch the Tests list, print the Results or both.
In this example the file contains a
Tests
Sheet to fetch tests list (image below) and another Tab namedResults
where to print the results.
- This file should have Tab names useful to either fetch the Tests list, print the Results or both.
In this example the file contains a
2. Identify the Google Sheet ID (visibile in theURL between `/d/` and before `/edit`).
Example for this URL https://docs.google.com/spreadsheets/d/1c3k9eEVg12Atoa72tglVVBg--o0CEMkOF3JCaLlxzeo/edit
the Google Sheet ID would be 1c3k9eEVg12Atoa72tglVVBg--o0CEMkOF3JCaLlxzeo
.
-
Download the service-account.json credentials from the Service accounts page and store them safely. In this example the file is stored inside a "tmp" folder.
-
Run the command selecting the appropriate tests and results connector. In this example 2 URLs are being tested via PSI API defined into a Google Sheet file Tab
Tests
and the results will be printed into theResults
Tab.
SERVICE_ACCOUNT_CREDENTIALS=./tmp/service-account.json CRUX_APIKEY=MY_API_KEY ./awp run sheets:[MY GOOGLE SHEET ID]/Tests sheets:[MY GOOGLE SHEET ID]/Results
- The expected outcome once the tests are completed looks as the following below:
- In order to create your AWP CrUX API Dashboard you can use this DataStudio template and follow the instructions below:
- Click on the "Use Template" button on the top left of the DataStudio template.
- Click on the "New Data Source" Dropdown and select "Create New Data Source".
- Select the "Google Shets" Google Connector.
- Look for your Google Sheets file, select the "Results" Tab and click on "Connect". .
- Now you should see all the sheets fields being populated and you can continue by clicking on the "Add to Report" button.
- Lastly click on the "Copy Report" button to create your own AWP CrUX API Dashboard getting results from the selected Data Source, your Google Sheet file.