Google Analytics Setup
The Dashboard widget reads your Google Analytics 4 data via the official Analytics Data API. That requires three things: a GA4 property, an enabled API, and a Google service account with the Analytics Viewer role. Total setup time is about five minutes.
1. Get your GA4 Property ID
- Sign in to Google Analytics.
- Select your account, then the property for your website.
An existing Universal Analytics (UA) property has a numeric ID in the form
123456789and gives you “GA4” sub-properties with IDs around 10 digits. Use the GA4 property ID for this module. - Open Admin (gear icon, bottom-left) → under Property choose Property Settings.
- Copy the Property ID (a plain number, e.g.
370550908) and paste it into the module’s GA4 Property ID field.
GA4 only — the module does not work with the old Universal Analytics
UA- ID. Create a GA4 property in Google Analytics if you do not have one yet.
2. Enable the Google Analytics Data API
The property above lives inside a Google Cloud project. The API must be turned on for that project before the module can query it.
- Open the Google Cloud Console project that owns the GA4 property. The fastest path is the direct enable link from the Google error message, substituting your project ID:
Yourhttps://console.developers.google.com/apis/api/analyticsdata.googleapis.com/overview?project=YOUR_PROJECT_IDYOUR_PROJECT_IDis shown in Google Analytics under Admin → Property → Property Settings → Property details. - Click Enable on the Analytics Data API page.
- It can take a few minutes for the API to propagate — the module’s Dashboard shows a “has not been used in project” message until then.
3. Create and download the Service Account JSON
The module authenticates as a Google service account (server-to-server). No OAuth consent screen or client-secret file is needed.
- Open the Google Cloud Console and select the same project as above (top bar project picker).
- Go to IAM & Admin → Service Accounts.
- Click + Create Service Account:
- Name it, e.g.
whmcs-seo-analytics. - Grant the role Google Analytics → Analytics Viewer (or create it first and add the role in step 6).
- Click Done.
- Name it, e.g.
- In the service account list, click the ⋮ menu of your new account → Manage keys → Add Key → Create new key → choose JSON → Create.
- A file named
something-like-1234.jsondownloads. Open it and copy the whole contents (it starts with{and contains"private_key"and"client_email"fields). - Make sure the service account has the Analytics Viewer role:
- In Google Analytics, open Admin → Property → Property Access Management → add the service account email from the JSON (
…@….iam.gserviceaccount.com) with the Viewer role; - or in Cloud Console set IAM → [service account] → Edit → Analytics Viewer role (this grants access to every GA4 property in the project).
- In Google Analytics, open Admin → Property → Property Access Management → add the service account email from the JSON (
4. Configure the module
- In WHMCS admin go to Addons → SEO Manager → Settings.
- Turn on Enable Google Analytics.
- Paste the GA4 Property ID from step 1.
- Paste the full service account JSON into the Service Account JSON textarea (JSON only — the module strips surrounding whitespace and any HTML entity encoding automatically).
- Save. Open the Dashboard — you should see live statistics within seconds.
Troubleshooting
| Dashboard message | Cause / fix |
|---|---|
Analytics Data API has not been used in project … | The API was enabled moments ago, or it is enabled in the wrong Cloud project. Wait a few minutes, then double-check step 2 — the project picker must match the GA4 property’s project. |
PERMISSION_DENIED | The service account is missing the Analytics Viewer role for the property (step 3.6), or the Analytics Data API is not enabled. |
Invalid grant / OAuth request failed | The client_email and private_key in the pasted JSON do not belong to the same service account key file — paste the file again without editing it. |
| Blocked by a firewall / proxy | The WHMCS server must be able to reach oauth2.googleapis.com and analyticsdata.googleapis.com over HTTPS. |
Data is cached for 1 hour, so after changing the key/ID click Save and (if the widget still shows old data) wait for the next refresh or check again later.