Google Analytics 4
Track the traffic of any Google Analytics 4 property.
What you get
Section titled “What you get”| Metric | Meaning in Google Analytics | Period value |
|---|---|---|
| Visitors | Total users | Exact unique users for the whole period |
| Visits | Sessions | Sum of the days |
| Page views | Views (page and screen views) | Sum of the days |
Days are counted in your property’s reporting timezone, so daily numbers match Google Analytics. The last three days are treated as provisional, because Google may still revise them.
Before you start
Section titled “Before you start”You need:
- Editor or Administrator access to the Google Analytics property, so you can add a user to it.
- A Google Cloud project where you can create a service account. Any free Google account can create one.
A service account is a Google account for software. You give it Viewer access to your property, the same way you’d add a colleague, and Metribay signs in as it. You can reuse the same service account for all your properties and for Search Console.
Step 1: Create a service account
Section titled “Step 1: Create a service account”-
Open the Google Cloud console and select a project, or create one called “Metribay”.
-
Go to APIs & Services → Library. Find and enable both Google Analytics Data API and Google Analytics Admin API. The Data API delivers your numbers; the Admin API lets Metribay list your properties and read their timezones.
-
Go to IAM & Admin → Service Accounts and select Create service account. Name it something like
metribay-reader. It doesn’t need any project roles: skip those steps and select Done. -
Open the new service account, go to Keys and select Add key → Create new key → JSON. A JSON file downloads. Keep it safe: it’s the account’s password.
-
Copy the service account’s email address. It ends in
iam.gserviceaccount.com.
Step 2: Give it access to your property
Section titled “Step 2: Give it access to your property”-
In Google Analytics, open Admin.
-
Under Property, select Property access management. To cover every property in the account at once, use Account access management instead.
-
Select + → Add users, paste the service account’s email address and choose the Viewer role. You can untick the email notification.
-
Select Add.
Step 3: Connect it in Metribay
Section titled “Step 3: Connect it in Metribay”-
Select Add source and choose Google Analytics 4.
-
Open Use your own credentials and paste the whole contents of the JSON key file into Service account JSON.
-
Select Save account and continue. Metribay checks the key.
-
Choose your property from the list. Its reporting timezone is filled in for you.
-
Pick a project and select Connect and start import.
You can delete the downloaded JSON file afterwards. Metribay keeps an encrypted copy.
Enter the property by hand
Section titled “Enter the property by hand”If the list is empty, open Enter a resource manually:
- Property ID: the number under Admin → Property details, like
412345678. It’s not theG-measurement ID. - Property reporting timezone: the timezone shown under Admin → Property details. It must match, or your days will be shifted.
Advanced: OAuth refresh token
Section titled “Advanced: OAuth refresh token”Instead of a service account, you can connect with your own Google OAuth app. Open Use OAuth credentials instead and fill in Client Id, Client Secret and a Refresh Token issued with the analytics.readonly scope. Leave Service account JSON empty. Use this only if you already manage a Google OAuth app.
If collection fails
Section titled “If collection fails”The property isn’t listed. The service account hasn’t been added to it, or the Admin API isn’t enabled. Check step 2, wait a minute, then select Refresh resources.
“Needs attention” after it worked before. Someone may have removed the service account’s access, or deleted its key. Add it again, or create a new key and update the saved account.
Sampled, thresholded or restricted data. Metribay won’t store numbers that Google has estimated, hidden or cut short. If Google applies thresholds, which often happens with Google signals turned on, the source needs attention. In Google Analytics, open Admin → Reporting identity and choose Device-based. This usually removes thresholds for these totals.
See also Troubleshooting.