When configured the Analytics Dashboard will provide high-level details on your website's statistics.
Enabling the API Access using Service Account
In order to rely on OAuth 2.0, our application must be authenticated and the user must grant access to it. To do so, several steps must be taken.
First, we need to log on to the Google Developers Console with our Google account and create a new project as seen below.
Name the project AdvantageCMS and leave the auto-generated Project ID as it is.
It will take a few seconds for the new project to be created.
Once the project is created, you will be redirected to its dashboard. Now, you need to enable the Analytics API and create a new access credentials.
After clicking on APIs in the left menu bar, you will be taken to the APIs list. Search for Analytics API and select and enable.
Once turned on, you will create new credentials by clicking the Credentials in the menu on the left.
Click on the Create Credentials button and Select the Service account key option.
This will take you to the Credentials detail page.
Under Service Account drop down, select App Engine default service account and select the P12 option and click Create.
A .p12 file will be downloaded to your computer and the service account key will be displayed under the service account keys list.
Click on the Manage Service Account link, on the far right, to check for the linked email.
Note the App Engine default service account email as seen below. This is the email address that needs to be entered in the CMS (Google login field) to set the analytics in the CMS.
Now that OAuth 2.0 access has been successfully created, the next step is to pair it with our website through Google Analytics.
Pairing with Google Analytics
The Reporting API credentials that have just been created can be used to access as many websites as you need to. All you need to do is add a new user for the desired website(s) using the Google Analytics User Management. As an email address, you need to use the email address that was generated for the OAuth 2.0 authentication in the previous step.
Therefore, you will use “email@example.com” in the email TextBox while leaving the default Read and Analyze permission since that is all you need in this case.
Retrieve the website code
websiteCode: This is the code of the website we have paired with the Reporting API. To get the code, the fastest way is to navigate to the settings of the desired website in Google Analytics and copy the eight digit code following the letter “p” from the URL of the browser.
Adding Google Client ID to Advantage CSP
- Go to Domain Management > Configurations Settings
- Go to the System tab
- Click on the pencil icon for Analytics
- Add in your Google Client ID and Site Code then click Save
- When you open the page, you will be prompted for security from Google
This is the implementation https://ga-dev-tools.appspot.com/embed-api/
To see an overview of the the dashboard when configured click the following article; Analytics: Dashboard Overview.