How can we help?

Table of Contents

Google Analytics Extension

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

  1. 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:
  2. Then go to your Google Cloud Console:
  3. And navigate to APIs & Services > Enabled APIs & services
    Google Analytics Extension 1
  4. Here we need to enable 3 APIs:
    1. Google Analytics Admin API,
    2. Google Analytics API, and
    3. Google Analytics Data API
      Google Analytics Extension 2
  5. Search for them one by one, and Enable them
    Google Analytics Extension 3
  6. Navigate to Credentials, click the + CREATE CREDENTIALS button, then OAuth client ID
    Google Analytics Extension 4
  7. Select Web application
    Google Analytics Extension 5
  8. Give it a desired name, and in the Authorized redirect URIs section, click the + ADD URI button, and enter
    NOTE: Replace the with your actual Dashboard URL
  9. Then click the Create button
    Google Analytics Extension 6
    NOTE: We will not be using this OAuth 2.0 Client IDs JSON file, so there is no need to download it.
  10. Click the + CREATE CREDENTIALS button again, and this time, select Service Account
  11. Give it a desired name, and click Done
    Google Analytics Extension 7
  12. Now click on the newly created Service Account, then KEYS tab
  13. Then click on the ADD KEY button, then Create new key
  14. From the popup modal, select JSON and then CREATE
    Google Analytics Extension 8
  15. JSON file will be downloaded automatically to your computer
  16. Now navigate back to your Google Analytics
  17. Open the Admin settings for your GA4 property, and open Property Access Management
    Google Analytics Extension 9
  18. Click on the Add users button
    Google Analytics Extension 10
  19. The email address we want to add can be found on the Credentials page on the Google Cloud Console
    Google Analytics Extension 11
  20. Enter it in the Email addresses field, set the role as Viewer, and click Add
    Google Analytics Extension 12IMPORTANT NOTE: Repeat steps 17 to 20 for each GA4 property you wish to see the data for in the MainWP Google Analytics extension
  21. Now navigate to your MainWP Dashboard > Extensions > Google Analytics > Add Account page, and upload the JSON file, which was downloaded automatically
    Google Analytics Extension 13
  22. The account should now be visible in the Manage Accounts tab
    Google Analytics Extension 14

    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


  1. Go to the MainWP > Sites > Manage Sites page
  2. Locate the desired child site and click the Edit action
    Google Analytics Extension 15
  3. Locate the Google Analytics section
  4. Select the correct property in the Google Analytics account property option
    Google Analytics Extension 16
  5. Click the Save Settings button
  6. Repeat the process for all your child sites
  7. When you are done, you will see those sites in the dropdown on the Extensions > Google Analytics > Visitor Data page
    Google Analytics Extension 17



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.

Google Analytics Extension 18

You can disable and enable widgets in the Page Settingsand you can re-arrange them in any way you wish.

Google Analytics Extension 19

To change the Child Site, simply select it from the dropdown menu.

Google Analytics Extension 20




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.

Google Analytics Extension 21



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.

Google Analytics Extension 22

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.
Google Analytics Extension 23

You can now upload that JSON Key file on the Add Account page to connect the account.

Google Analytics Extension 13

Still Have a Questions?
Search for additional solutions in the MainWP Community or start your own discussion