What You’ll Learn
- Enabling required Google Cloud APIs
- Creating and configuring a Service Account
- Connecting Google Analytics to MainWP
- Viewing visitor data across all child sites
Use this Extension To Track:
- Views
- Views by Page
- Users
- Users by Device
- Users by Country
- New Users
- Average Engagement Time
- Sessions by Source
Establishing a connection with Google Analytics
First we will enable the 3 necessary APIs in Google Cloud Console.Go to your Google Cloud Console: https://console.cloud.google.com
Create a new Project

Navigate to APIs & Services > Enabled APIs & services

Here we need to enable 3 APIs:
- Google Analytics Admin API,
- Google Analytics API, and
- **Google Analytics Data API

**Search for them one by one, and Enable them\
- In Google Cloud Console, Navigate to APIs & Services, click the + Create credentials button, select Service Account
- Give it a desired name, and click Done\

- Now click on the newly created Service Account, then KEYS tab
- Then click on the Add Key button, then Create new key, select JSON and click Create**
** - JSON file will be downloaded automatically to your computer
Or it can be added to individual GA4 properties which requires more upfront work but allows for more granular access.
Navigate to your Google Analytics Dashboard and open the Admin settings
Chose if you want to add the Service Account to the entire GA account or a single, currently selected, property

Click on the Add users button

The email address we want to add can be found on the Credentials page on the Google Cloud Console

Enter the email, set role as Viewer, and click Add

Now navigate to your MainWP Dashboard > Add-ons > Google Analytics > Add Account page, and upload the JSON file, which was downloaded automatically

The account should now be visible in the Manage Accounts tab

NOTE: Multiple Google Accounts can be added by repeating the same process.
Assigning sites from your Google Account to Child Sites in your MainWP Dashboard
The add-on will automatically assign properties to Child Sites based on the Child Site’s URL. However, you can still manually assign properties to child sites, by doing the following:Go to MainWP > Sites > Manage Sites

Locate the desired site, click on it's name and then open its Settings page
Find the Google Analytics section and select the matching Property
Click Save Settings.
Google Analytics Visitor Data
After you connect your Google Analytics account and assign GA4 properties to your Child Sites, you will be able to see all Google Analytics data on the Extensions > Google Analytics > Visitor Data page**.**


Widgets
Google Analytics widget will be added to the Overview page and on the Individual Child site Overview page. As always, the widgets can be enabled or disabled in the Page Settings, and they can be re-arranged however you wish.
Resolve the issue with account Disconnection
If the Service Account on the Google Cloud Console is temporarily Disabled, the connection may break in the MainWP Google Analytics extension.


Related Resources
- Analytics Add-ons - Browse all analytics integrations
- Pro Reports Extension - Include analytics data in reports
- Available Pro Reports Tokens - Google Analytics tokens