Set up Google Analytics
Setting up the integration for Google Analytics has a number of steps, but if you follow the directions below you should be able to set it up without an issue. In large part this is due to the complexity of Google’s products and the requirements they have.
We opted for the Service type of integration rather than a simple OAuth integration. This has a few more steps, but is far less likely to break and also is not confusing for our users about what analytics data of yours we would have access to (none).
If you are less concerned with security, you can save yourself time by re-using the service account across multiple websites. This would mean you only have to do the last two “sections” of this for each site.
- This assumes that you have a Google Analytics account already set up, and that you are already tracking data on your website using it. This plugin does not add the necessary tracking tags on your website for Google Analytics to work. That is the job of another plugin.
- You will need to have the ability to manage users on the Google Analytics account! This allows you to add the necessary user to the account. If you only have read only access, you will have to ask the owner to give you that permission or add the service account email address we create below for you.
Create an API Project
- Start by navigating to the Google Developers Console and Log in using your Google account.
- Once you are logged in, you’ll want to create a New Project. In the header, to the right of the GoogleAPIs logo is a dropdown menu. Open that and select New Project.
- Enter a Project name and click Create, this will take a few seconds to finish. When it does finish make sure to click into that project so that it says the project name in the header.
Enable Google Analytics API
- From the top left Hamburger Menu, choose APIs and Services and choose Library.
- Search for Analytics. Be sure to choose the Google Analytics API not the Google Analytics Reporting API.
- Within the Google Analytics API click Enable.
Create a Service Account & Key
- Click Credentials or Create Credentials.
- Choose Service account.
- Name the service account. It could be “Website”, or the name of your website, or it could be WP Client Reports Plugin. Whatever you choose. Optionally add a description. Click Create.
- You do not need to set up any service account permissions or roles. Click Continue.
- You do not need to grant any users access to this service account.
- You do want to create a key! Create the JSON type key, it will download a file like funky-uncle-687965-456hsdfk5e6thdfg.json to your computer.
- Click Done.
- This is important! You are not done yet! Copy the service account “email address” that you just created and keep it for the next step. It will look like email@example.com depending on the name you gave to it and the random names/numbers it assigns.
- If you are less concerned with security between accounts (this will only be for read-only data), you could re-use this same account for all of your sites.
Add Account to Google Analytics
- You will now log in to your Google Analytics account.
- Once logged in, choose the website you want to give access to by using the menu to the right of the Analytics logo.
- Click admin in the bottom left corner.
- Under account, choose Account user management.
- Click the blue plus button in the top right corner to add a new user.
- Paste in the Service account email address you created earlier. All it needs is Read & Analyze permissions and click Add.
Upload Key File to WP Client Reports Pro
- Log in to your WordPress site and go to Settings > WP Client Reports.
- Enable Google Analytics and click Save.
- Upload the .json key file from steps above and click Save.
- You may need to select an account and click Save.