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 Account
- Follow the steps outlined in this Google Analytics help document to create a new GA4 property if you don’t already have one, and add a Web data stream: https://support.google.com/analytics/answer/9304153
- Then go to your Google Cloud Console: https://console.cloud.google.com
- And navigate to APIs & Services > Enabled APIs & services
- Here we need to enable 3 APIs:
- Search for them one by one, and Enable them
- Navigate to Credentials, click the + CREATE CREDENTIALS button, then OAuth client ID
- Select Web application
- Give it a desired name, and in the Authorized redirect URIs section, click the + ADD URI button, and enter https://your-dashboard-url.com/wp-admin/admin.php?page=Extensions-Mainwp-Google-Analytics-Extension&mainwp_ga=1
NOTE: Replace the your-dashboard-url.com with your actual Dashboard URL - Then click the Create button
NOTE: We will not be using this OAuth 2.0 Client IDs JSON file, so there is no need to download it. - Click the + CREATE CREDENTIALS button again, and this time, 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
- From the popup modal, select JSON and then CREATE
- JSON file will be downloaded automatically to your computer
- Now navigate back to your Google Analytics
- Open the Admin settings for your GA4 property, and open Property Access Management
- 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 it in the Email addresses field, set the role as Viewer, and click Add
IMPORTANT NOTE: Repeat steps 17 to 20 for each GA4 property you wish to see the data for in the MainWP Google Analytics extension
- Now navigate to your MainWP Dashboard > Extensions > 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.
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
- Go to the MainWP > Sites > Manage Sites page
- Locate the desired child site and click the Edit action
- Locate the Google Analytics section
- Select the correct property in the Google Analytics account property option
- Click the Save Settings button
- Repeat the process for all your child sites
- When you are done, you will see those sites in the dropdown on the Extensions > Google Analytics > Visitor Data page
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.
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.
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.
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.