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
Integration Add-on - This add-on extends MainWP to work with Google Analytics. Requires Google Analytics to be installed on your child sites.
The MainWP Google Analytics Extension gives you valuable insights into your visitor’s search and traffic patterns, your marketing campaigns, and much more, allowing you to optimize your strategy and the online experience of your users.
Use this Extension To Track:
- Views
- Views by Page
- Users
- Users by Device
- Users by Country
- New Users
- Average Engagement Time
- Sessions by Source
NOTE: Due to the change in authentication method, users updating to version 4.1 of the extension will have to re-add their Google Analytics account by following the steps below.
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
Create a new Project\
Navigate to APIs & Services > Enabled APIs & services
Navigate to APIs & Services > Enabled APIs & services\
Here we need to enable 3 APIs:
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\
Next, we will create a Service Account which will be added as a viewer later on to desired GA4 properties.
- 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
Next, we will add the Service Account as a Viewer to desired properties.
The Service Account account can be added as a Viewer to the entire Google Analytics account in which case, it will have access to all properties within that account.
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
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
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
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
Enter the email address in the Email addresses field, set the role as Viewer, and click Add.
IMPORTANT NOTE: If you decided to add the Service Account as a Viewer to a single property, repeat the steps above to all other desired single properties. Now navigate to your MainWP Dashboard > Add-ons > Google Analytics > Add Account page, and upload the JSON file, which was downloaded automatically
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
The account should now be visible in the Manage Accounts tab

NOTE: Multiple Google Accounts can be added by repeating the same process.
Important Notes:
The Google Analytics Extension doesn’t allow you to insert the Google Analytics tracking code on your child sites. To do that, you will need to add the code manually or use a 3rd party plugin.
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
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
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 Add-ons > Google Analytics > Visitor Data page**.**
You can disable and enable widgets in the Page Settings, and you can re-arrange them in any way you wish.
To change the Child Site, simply select it from the dropdown menu.
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.
To reconnect the Google Analytics account, re-enable the Service Account, and navigate to KEYS. Then from the ADD KEY dropdown, select Create New Key and download the JSON Key file.\
You can now upload that JSON Key file on the Add Account page to connect the account.