Google Analytics

Available with the following:
MainWP Core + Pro Add-on
Additional Requirements:
This extension requires a valid Google Analytics account and an API key.
Table of Contents

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

You can connect the Google Analytics account in two ways. Use whichever fits your setup (you can use both):

Option A: Sign in with Google (OAuth)

1. In your MainWP Dashboard, go to MainWP > Add‑ons > Google Analytics > Add Account.
2. Click Sign in with Google and follow the on-screen prompts to complete authorization.
3. Next, select the Google Analytics account you want to connect, then click Continue and then Confirm.
4. Selected Analytics account will appear under Manage Accounts

Option B: Connect a Service Account (JSON file)

First we will enable the 3 necessary APIs in Google Cloud Console.

  1. Go to your Google Cloud Console: https://console.cloud.google.com
  2. Create a new Project
  3. Navigate to APIs & Services > Enabled APIs & services
  4. Here we need to enable 3 APIs:
    1. Google Analytics Admin API,
    2. Google Analytics API, and
    3. 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.

  1. In Google Cloud Console, Navigate to APIs & Services, click the + Create credentials button, select Service Account
  2. Give it a desired name, and click Done
  3. Now click on the newly created Service Account, then KEYS tab
  4. Then click on the Add Key button, then Create new key, select JSON and click Create
  5. 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.

  1. Navigate to your Google Analytics Dashboard and open the Admin settings
  2. Chose if you want to add the Service Account to the entire GA account or a single, currently selected, property

  3. Click on the Add users button
  4. The email address we want to add can be found on the Credentials page on the Google Cloud Console
  5. Enter it 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.
  6. Now navigate to your MainWP Dashboard > Add-ons > Google Analytics > Add Account page, and upload the JSON file, which was downloaded automatically
  7. 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:

  1. Go to MainWP > Sites > Manage Sites.
  2. Locate the desired site, click on it’s name and then open its Settings page
  3. Find the Google Analytics section and select the matching Property
  4. 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.

You can disable and enable widgets in the Page Settingsand 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.

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

Table of Contents

Search MainWP.com

[searchwp_form id="1"]