A reusable template for setting up automated page health monitoring with GTmetrix, Lighthouse, BigQuery, and Looker Studio.
Clone this repository and follow the steps below to get a full performance monitoring pipeline running for your project.
- BigQuery Project Setup
- Page Health Performance Dashboard
- Visualize Performance Trends in Looker Studio
Warning
BigQuery Sandbox Limitation: Mandatory 60-Day Expiration
If your Google Cloud project does not have a linked billing account, it operates in Sandbox mode. In this mode, Google Cloud enforces a mandatory 60-day expiration for all datasets and tables.
- The Risk: Your performance data will be automatically deleted after 60 days.
- The Restriction: You cannot change the expiration to "Never" while in Sandbox mode.
- The Solution: To ensure your data is preserved indefinitely, you must link a billing account to your project. This will allow you to set the dataset and table expiration to "Never".
- Navigate to the Google Cloud Console
- Create a new project (e.g.,
My Project Performance) - Note down your Project ID and Project Name
- In Cloud Console, search for "BigQuery API"
- Click "Enable" to activate it
- Go to IAM & Admin → Service Accounts
- Click "Create Service Account"
- Fill in:
- Service Account Name (e.g.,
performance-dashboard) - Service Account ID (auto-filled)
- Service Account Name (e.g.,
- Click "Create and Continue"
- Set the role to BigQuery Admin
- Note the service account name, ID, and email
- Click on the created service account
- Go to the "Keys" tab
- Click "Add Key" → "Create new key"
- Select JSON format and click "Create"
- Save this file securely — you will need it in subsequent steps
- Open the BigQuery Console
- Click "Create Dataset"
- Set a Dataset ID (e.g.,
performance_data) - Keep all other defaults and click "Create dataset"
Select the dataset you just created, then click "Create Table" for the table below.
GTmetrix / Page Health table — paste the following JSON under Schema:
[
{ "name": "report_id", "type": "STRING", "mode": "NULLABLE" },
{ "name": "page_name", "type": "STRING", "mode": "NULLABLE" },
{ "name": "url", "type": "STRING", "mode": "NULLABLE" },
{ "name": "gtmetrix_score", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "performance_score", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "structure_score", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "largest_contentful_paint", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "time_to_first_byte", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "cumulative_layout_shift", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "fully_loaded_time", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "page_size", "type": "INTEGER", "mode": "NULLABLE" },
{ "name": "seo_score", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "accessibility_score", "type": "FLOAT", "mode": "NULLABLE" },
{ "name": "report_grade", "type": "STRING", "mode": "NULLABLE" },
{ "name": "test_date", "type": "TIMESTAMP", "mode": "NULLABLE" },
{ "name": "report_url", "type": "STRING", "mode": "NULLABLE" },
{ "name": "env", "type": "STRING", "mode": "NULLABLE" }
]Click "Create table".
This section sets up the GTmetrix + Lighthouse pipeline that runs automatically via GitHub Actions.
git clone https://github.com/ColoredCow/performance-dashboard.git
cd performance-dashboardFollow the steps in Section 1 above.
Create a file named bigquery-writer-key.json at the root of the project and paste the contents of the JSON key downloaded in Step 1.4:
{
"type": "service_account",
"project_id": "YOUR_PROJECT_ID",
"private_key_id": "YOUR_PRIVATE_KEY_ID",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "YOUR_SERVICE_ACCOUNT_EMAIL",
"client_id": "YOUR_CLIENT_ID",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "YOUR_CLIENT_CERT_URL",
"universe_domain": "googleapis.com"
}This file is already listed in
.gitignore— it will never be committed.
Copy .env.example to .env and fill in your values:
cp .env.example .envGT_API_KEY=your_gtmetrix_api_key # From your GTmetrix account → API settings
PROJECT_ID=your-google-cloud-project-id
DATASET_ID=your-bigquery-dataset-id
TABLE_ID=your-bigquery-table-id
SERVICE_ACCOUNT_KEY=./bigquery-writer-key.jsonOpen config/urls.js and update the list of URLs you want to monitor. You can categorize them as live or uat using the env property.
export const URLS_TO_TEST = [
{ label: "Home Page", url: "https://your-site.com/", env: "live" },
{ label: "UAT Home Page", url: "https://uat.your-site.com/", env: "uat" },
// ... add more URLs here
];npm installYou can run the script for a specific environment by setting the TARGET_ENV environment variable. If not specified, it defaults to live.
Run these commands in your terminal:
- Test Live Environment:
TARGET_ENV=live node index.js
- Test UAT Environment:
TARGET_ENV=uat node index.js
Option 1: Using Command Prompt (CMD)
- Test Live Environment:
set TARGET_ENV=live && node index.js
- Test UAT Environment:
set TARGET_ENV=uat && node index.js
Option 2: Using PowerShell
- Test Live Environment:
$env:TARGET_ENV="live"; node index.js
- Test UAT Environment:
$env:TARGET_ENV="uat"; node index.js
Tip
Alternatively, you can add TARGET_ENV=uat or TARGET_ENV=live directly into your .env file to set a persistent default for your local machine.
What happens:
- GTmetrix tests run for all URLs matching
TARGET_ENV(defaults tolive) - Local Lighthouse collects SEO and accessibility scores
- All metrics are inserted into your BigQuery table
Ensure you have run the script at least once so that data is available in BigQuery. You can then move to Section 3 to set up your Looker Studio dashboard.
- Push the repository to GitHub
- Go to Settings → Secrets and variables → Actions and add these secrets:
| Secret name | Value |
|---|---|
GT_API_KEY |
Your GTmetrix API key |
PROJECT_ID |
Your Google Cloud project ID |
DATASET_ID |
Your BigQuery dataset ID |
TABLE_ID |
Your BigQuery table ID |
SERVICE_ACCOUNT_KEY |
Full contents of your bigquery-writer-key.json |
- Enable the cron schedule in
.github/workflows/run-performance-tests.yamlby uncommenting thescheduleblock:
on:
schedule:
# Runs twice daily — adjust cron times to match your preferred schedule (times are UTC)
- cron: "30 4 * * *" # Example: 4:30 AM UTC
- cron: "30 14 * * *" # Example: 2:30 PM UTC
workflow_dispatch:Adjust the cron times to match your preferred schedule (all times are UTC). Commit and push this change to activate the automated runs.
- The workflow will now run on the configured schedule automatically.
End-to-end flow:
GitHub Actions (scheduled) → GTmetrix + Lighthouse → BigQuery → Looker Studio
Once your automated tests are running and populating BigQuery, you can build a professional dashboard in Looker Studio to monitor trends over time.
- Open Looker Studio.
- Create a New Report.
- Add a data source → Select BigQuery.
- Select your Project, Dataset, and Table created in Section 1.
- Click Add.
To create a dashboard showing GTmetrix Score, Page Size, Load Time, and Accessibility trends:
- Chart Type: Time Series Chart.
- Dimension:
test_date(Set type to Date or Date & Time).
In the Data pane, click Add Field to create user-friendly metrics:
- Page Size (MB):
page_size / 1048576 - Fully Loaded Time (sec):
fully_loaded_time / 1000
Drag the following into the Metric section of your charts:
gtmetrix_scorefully_loaded_time(or your calculated seconds field)page_size(or your calculated MB field)accessibility_score
To isolate a specific page (e.g., "Product Details Page") and environment (e.g., "uat"):
- Add a Filter to the chart or the page.
- Set
page_nameEqual toProduct Details Page. - Set
envEqual touat.
To track your performance against goals (e.g., a GTmetrix score of 80+):
- Select a chart and go to the Style tab.
- Click Add a reference line.
- Set the Type to
Constant Value. - Enter your target (e.g.,
80for score,3for seconds). - Set the line style to Dashed and color to Red.
- Add a Label (e.g., "GTM (80)").