Google have created an extremely comprehensive API linking to Analytics which allows us to harness the powerful reporting capabilities of Google for tracking visitor numbers, conversion rates and other transactional data.
We have integrated Google’s Analytics API with the IRP for use within the IRP’s own Statistics section and also in IRP World. Statistics are sought from both the IRP and from Google Analytics and this data is combined to provide a comprehensive analysis of a client’s month-by-month progress.
Google have written their own documentation on how to access the Analytics API:
https://developers.google.com/analytics/solutions/articles/hello-analytics-api
There are 3 steps involved in enabling access to the Google Analytics API from a client’s IRP:
- Log in to Google
- Register project in Google Developers console
- Configure IRP Statistic Settings
Step 1. Log In to Google
Please ensure that when logging into Google, the account being used has full access rights to Google Analytics. If the account does not have the sufficient permissions to access Analytics, please ask someone with greater access rights to grant permission to the Google account.
Once logged in to an appropriate Google account, verify that the account has access to Google Analytics. Once verified, move to Step 2.
Step 2. Register Project in Google Developers Console
To access the Google Analytics API from a client IRP, a project must be created in the client’s Google Developers Console. This process can be broken down into the following steps:
- Create API project
- Enable Google Analytics API on new project
- Set Up Credentials and Create a Key File
- Add Permissions for the Project in Google Analytics
- Create API Project
- Go to the Google Developers Console and create a project to talk to the IRP:
https://console.developers.google.com/project?authuser=0
- Click Create Project:
- Enter the Project Name API Project.
- Leave the Project ID as the automatically generated value.
- Tick the check box agreeing to the Terms of Service.
- Click Create.
- Google will redirect to the newly created project dashboard:
- Enable Google Analytics API on New Project
- Click Enable and manage APIs.
- Scroll down to the Advertising APIs section, click Analytics API and select Enable API.
- Set Up Credentials and Create a Key File
- Select Credentials from the left navigation menu in the Project Dashboard.
- Using the New Credentials drop-down menu, select Service Account Key.
- Select a name for the account and select the P12 option for the key type:
- Click Create.
The key file is now downloaded to your Downloads folder by default, from where you can upload it to the IRP via the OAuth P12 Key setting on the IRPStatisticsSettings.aspx screen (see Step 3 in the following section).
- Add Permissions for the Project in Google Analytics
- Click Manage service accounts on the right side of the main Credentials screen.
- Copy the Email address.
- You use this email address to populate the OAuth Email Address setting on the IRPStatisticsSettings.aspx screen (see Step 3 in the following section).
- Open Google Analytics and navigate to Admin > User Management > Add Permissions for.
- Allow ALL permissions using the drop-down menu.
- Click Add.
Step 3. Configure IRP Statistic Settings
There are several IRP Statistic Settings associated with the Google Analytics API that you need to configure. To access these, click the cog wheel icon in the top-right corner of the IRPStatistics.aspx screen (you can find this page by going to Statistics > Monthly Statistics or by clicking the 'Enter Costs' button in the bottom nav). You will then be on the IRPStatisticsSettings.aspx page where you can enter values for the following settings in the Google Analytics Settings section:
- Profile ID
To find this:
- Log in to the Google Analytics Dashboard and click Admin on the top navigation bar.
- Click View Settings in the View column.
- The View ID (Profile ID) is located under the heading View ID under View Settings.
- OAuth Email Address
You can find this in the Permissions section of the Google Developers Console, on the Service Accounts tab. This is the oAuth Email Address connected to the Service account set up against your API Developer's Project in Google Analytics.
- OAuth P12 Key
You can get this file in the Credentials section of the Google Developers Console, on the Service Accounts tab. Use this to upload the oAuth .p12 authentication key for your developer's app's Service account.
You can automate statistics by clicking the Automation tab and selecting to repeat on a Daily, Hourly, Weekly or other basis (Daily is generally sufficient). You can also select the time when the automation should first be run.
When you have entered these details, click the Update IRP Statistics button.
NOTE: For other important IRP World settings, see the following help topics: Monthly Statistics (for Statistics Settings) and Common Tasks (for the 'Auto Update IRP Statistics' Common Task).