SEO Managerfor WHMCS · Documentation
v1.0.0

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

  1. Sign in to Google Analytics.
  2. Select your account, then the property for your website.
    An existing Universal Analytics (UA) property has a numeric ID in the form 123456789 and gives you “GA4” sub-properties with IDs around 10 digits. Use the GA4 property ID for this module.
  3. Open Admin (gear icon, bottom-left) → under Property choose Property Settings.
  4. 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.

  1. 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:
    https://console.developers.google.com/apis/api/analyticsdata.googleapis.com/overview?project=YOUR_PROJECT_ID
    Your YOUR_PROJECT_ID is shown in Google Analytics under Admin → Property → Property Settings → Property details.
  2. Click Enable on the Analytics Data API page.
  3. 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.

  1. Open the Google Cloud Console and select the same project as above (top bar project picker).
  2. Go to IAM & Admin → Service Accounts.
  3. 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.
  4. In the service account list, click the ⋮ menu of your new account → Manage keys → Add Key → Create new key → choose JSON → Create.
  5. A file named something-like-1234.json downloads. Open it and copy the whole contents (it starts with { and contains "private_key" and "client_email" fields).
  6. 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).

4. Configure the module

  1. In WHMCS admin go to Addons → SEO Manager → Settings.
  2. Turn on Enable Google Analytics.
  3. Paste the GA4 Property ID from step 1.
  4. 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).
  5. Save. Open the Dashboard — you should see live statistics within seconds.

Troubleshooting

Dashboard messageCause / 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_DENIEDThe 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 failedThe 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 / proxyThe 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.