New GA4 Extension

I managed to successfully connect one site using the new GA extension 4.1. Followed the steps and everything worked well. As I have over 100 sites to connect, is the procedure different to connect all of them using the same Json file, or do I need to create a new Json file and Key for each site?

I entered the same service email address in a few of my site’s GA4 Property accounts, then downloaded the new JSON file and tried to use that. Initially, I noticed that the few sites that I was testing showed in MainWP, but when I tried to link the GA account to the child site in MainWP, that is where I ran into problems. At first, the connection would just hang and nothing would happen, then the extension broke and I just received a white screen, saying there was a critical error in my MainWP dashboard site. I then deactivated the Extension and was able to continue to use MainWP.

I updated GA Extension to 4.1.1, and I am now able to get back into the GA Extension page in MainWP. I had already deleted the previous JSON files, so now it is back to the start.

Hence my question about connecting multiple sites, is this possible, or do I need to connect each one separately, using new keys and JSON files for each? The instructions are quite good and as mentioned I managed to connect one site and it showed perfectly in MainWP.

I’m in the same spot as you.

I also set up one site and everything seemed fine, then I changed the display interval from ‘1 Week’ to ‘1 Month’ and received a critical error. I had to delete the json file from the /uploads/mainwp/google-analytics/ folder and delete the plugin to get back in.

I created a new json key and uploaded that, connected 3 sites in the MainWP dashboard to their respective analytics profile, however only one of them is showing data.

The setup instructions do not clearly explain how to set up more than one website.

Looks like you need to run through the entire process for each site, so:

  1. Create OAuth Client ID
  2. Create Service Account
  3. Download JSON Key
  4. Upload JSON key to MainWP
  5. Add service account email address as a user to the website GA profile
  6. In MainWP attach GA account to website in settings

Pretty tedious, especially if you have hundreds of sites. But a few cups of coffee and a weekend and it should all be good :sweat_smile:

Thank you for your comments. I also put a support ticket in over the weekend and was waiting for confirmation. Surprising if this is the case taking into account that most people who use MainWP would have multiple sites. It was a massive job changing all the child sites from UA to GA4, and now this.

Appreciate your update and it would have been good if MainWP had of included those details in the How to for GA. All the best.

1 Like

Yes I’m still waiting to hear back from support as well. I also tried creating multiple keys, and also creating multiple Service Accounts. But it only worked by creating multiple OAuth and Service Accounts for each property. I guess it’s just a limitation of Google’s API which is a shame.

OK, yes, I have successfully done three. One thing i noticed is you need to do it in the order of the GA How to Guide. I had a problem with one site not showing data. I put the email user in GA Property, then created the Key, which seemed to cause a problem. Went back and did it as per the guide and all good. One 105 to go.

I’ve successfully added the json file to the MainWP Google Analytics extension but under manage account and the status column it says disconnected for the account.

I am using the original OAuth 2.0 Client IDs I had used for UA. Do I need to delete this and recreate everything?

You only need one Service Account and one JSON Key file to connect multiple sites that may exist in one Google Analytics account.
However, the email address of that Service Account has to be added to each site on the Google Analytics dashboard as a Viewer in the Property Access Management (step 17).

OAuth 2.0 Client ID is not used to connect Google Analytics account.

Last Friday, we’ve released a hotfix version 4.1.1 of the extension.
It resolves the error caused by uploading the incorrect JSON Key file.
We have also added an additional guardrail which will look for an incompatible JSON Key file and reject the upload if found.

After you update the extension, remove any disconnected account you may have and follow the steps outlined in this help article to add a GA account using a Service Account JSON Key: Google Analytics Extension - MainWP Documentation

Yup I know not to use the json file from the OAuth 2.0 Client ID. I used the one from the Service Account I created following the instructions from your link (and I also added the permission to the appropriate GA4 property). The creation of the OAuth 2.0 Client ID seems to be the same as before (for UA properties) and I didn’t think it needed to be deleted and added a new one.

Anyways I did add a new one now but now realize what the problem was. I had Google Analytics API enabled but not Google Analytics Admin API or Google Analytics Data API. Once I enabled those and re added the json file for the connection it worked.

1 Like

Hi, good to see it’s only one JSON / service account, however, I’m only seeing data from the last Child Site I connected. I methodically went through all the steps and the connection seems good.

All of my sites are listed in the dropdown for connecting a Google Analytics account, but when I head on over to Visitor Data I only see data for the last child site I connected. Is there a waiting period? Any possible conflicts? Thanks!

@bojan . Ok, to test a couple of sites in my MainWP, I went back to Google Cloud and created a Master OAuth, Service Account, and Keys. Then included the email address in four sites GA Property Access.

Once I uploaded the JSON file, I found that it showed the properties in MainWP and I was able to allocate the property to the site on the Edit screen.

However, when checking the site in MainWP, there was no data for any of them.

Originally I was asked by support: Do you have all your sites connected to the same Google Analytics account?

I think this is where the confusion has arisen for me. I have a Google Analytics Account and within that GA account, I have separate Analytics Accounts for each client website. Within each of those Analytics Accounts, they have both the current UA and GA4.

So, if I understand this correctly, for this to work from the same email recorded in the Service Account, all of my existing GA4 properties, for all sites, need to be in the one Google Analytics Account?

As I have separated them into their own Analytics Accounts, I think I need an OAuth, Service Account, and Key for each property.

This is interesting to me when looking after multiple client sites, is the correct procedure for GA to have one account and include all properties in that one account?

The way I run my agency is that my customers have their own Google Analytics accounts. I have them share access their Analytics properties to my agency google account. This agency google account is what I use to manage all customer accounts and the one I have configured for the Google Cloud API for the MainWP extension. I don’t know enough about the api to know if it allows for the viewing of analytics data that is owned by another google account. I do know that I can see my customers accounts in MainWP (linked through my single google account), but it is not populating any data.

I really hope there is a solution that only requires setting up access to the API once. To have to do this for each customer account would be wildly tedious.

This is what i have discovered.

If you have all your sites in separate Google Analytics Accounts, then you need to create OAuth, Service Account, and Key for the GA4 Property within that account.

If you have all your sites in one Google Analytics Account. So, one account with all your GA4 properties then once you create the OAuth, Service Account, and Key and then include the Service Account email address in all those properties, they will work in the Main WP GA extension. Don’t forget to allocate the correct GA account on the Edit page of your MainWP Child sites.

1 Like

Thanks for the insight, but this doesn’t quite match what I am experiencing. One of my sites that I am working with is owned by the same google account as the google cloud api is configured, but I am still not receiving any data.

I actually just discovered that a new OAuth account is not necessary. You can simply create a service account and json key for each property. Then just link the service account email address to ONE property. It doesn’t matter which analytics account the property is a part of it.

1 Like

Hi @kitzmillercreative2

Did you assign the GA properties to the child sites as explained in this doc? Google Analytics Extension - MainWP Documentation

After you assign them, they should become immediately visible in the dropdown on the Extension > Google Analytics > Visitor Data page.

Hello @bojan , I also have the same problem as @kitzmillercreative2 . I can see all GA accounts but only the last one connected shows data…

I transfered my post in the support topic:

1 Like

I have confirmed that you need to create a Service account and unique Email/JSON Key for each client site. It’s a tedious process but it’s working for me.

My process is:

  • Create a Service Account
  • Create and download JSON Key file within the Service Account you just created
  • Upload a new JSON file in MainWP (confirm by seeing if it is listed in the Manage Accounts tab in MainWP.
  • Add the associated Service Account email to the client’s GA4 property (It can take a second for this to take. I get an error sometimes when adding the email to GA. Wait 60 seconds and keep trying)
  • Go back to MainWP and assign the GA property to the client under the Edit screen.
  • Head over to the Google Analytics extension to see if data is showing up.

In our testing, it is not necessary to create a Service Account and unique Email/JSON Key for each client site.

One Service Account can be used to fetch multiple property data.

However, it may be necessary to have a separate Service Account for each Analytics Account you may have in your Google Analytics Dashboard.

We are investigating if it’s possible to streamline this process further.