The Google Analytics Pageviews module is designed to support metrics from the GA4 API/Google Analytics Reporting API connected to the Google Analytics App. Google Analytics platform is scheduled to switch to from Universal Analytics (UA) to Google Analytics (GA4) by July 1, 2023. Google Analytics is designed to provide simple integration with the GA4 APIs.
Google Analytics Pageviews is the API monitoring resource designed to extract and process information related to the Pageviews metrics.
Users must have a valid Google Analytics account with registered Application that is able to pull analytics data of the resource. Users must also have the necessary right and privileges on Google Cloud Platform to register and authorize the API access.
- Ensure that applications is registered with Google Analytics Platform. The configuration must include:
Admin/Account Access Managementmust have correct email setup for the API account, whether it is standard email or the service account.
Admin/Property Settingsmust exist for the current asset and the asset must have a valid Property ID.
Admin/Property Access Managementmust be aligned with Account Access Management to provide adequate privileges to the information.
Admin/Data Streammust be configured to collect Pageviews metrics and the asset must tagged per Google data stream instructions.
- Ensure that Google Cloud Platform is setup correctly under APIs and Services:
Enabled APIs and Servicesmust include
Analytics Reporting APIwhich can be added and enabled from the API library.
Oauth Consent Screenmust register basic information about the application. Oauth users with their Google email credential should be added to list.
Credentialssection shall be confirmed to include Ouath 2.0 ClientIDs. This section will provide the Client ID and the Client Secret that are required for the datasource. For the purpose of this documentation we will be using Google Oauth Playground, so our redirect information would need to correspond with the Playground requirements.
Google Analytics supports the following web assets:
- Web - Android App - iOS App
User must have direct access to the assets to property tags the assets and give sufficient privileges to the Google Analytics account to be able to collect the data from the resource.
Additional Setup (Oauth Playground)
To properly setup Oauth with Google account, use Google Oauth Playground.
- Oauth 2.0 configuration: Select the gear icon at the top right of the corner and include the following parameters:
- Oauth flow: Server-side
- Oauth Endpoint: Google
- Authorization endpoint: Default
- Access token location: Prefix with Bearer token
- Force Prompt: Consent Screen
- Select Provide your own Oauth credentials. Ensure that GCP redirect URI matches https://developers.google.com/oauthplayground and that client ID/client secret match the credentials from GCP.
On the left corner, select Step 1. Under Analytics Reporting API v4 https://www.googleapis.com/auth/analytics and click Authorize API. This will create the request/response that provides the authorization code and will generate the promp for Google Account Authorization
Step 2 of the Oauth Playground generates the refresh token and the access token. Only refresh token is required for the data source field.
Step 3 allows for the user to test the API endpoints. Ensure that you are able to get a 200 response with the Batch GetReports endpoint.
Module Properties Requirements
- analytics.client.id (Google API user)
- analytics.clientsecret.pass (Google API secret)
- analytics.refreshtoken.pass (Google refresh token) (can be obtained through oauth playground)
- analytics.propertyId (Google Analytics Project – PropertyID)
- analytics.startdate (Ex: yesterday, 7daysAgo, 2015-01-01)
- analytics.enddate (Ex: yesterday, 7daysAgo, 2015-01-01)
This module can be applied through either Netscan or Active Discovery scheduler, given that
AppliesTo instance property have been provided by the user. Required properties shall meet the listed requirements above.
Assign Properties to Resources
In order for the resource to be discovered target device/collector should have the required properties. Once the
AppliesTo requirements for the datasource are met, datasource should appear after the next Active Discovery cycle.
Considerations, Warnings, and Troubleshooting
Due to the fact that you are dealing with multiple portals with each having their own privileges the user must be weary of the following errors:
- Error Code 401: Authorization error. This is associated with the ability of the API to access the data. It can only be a temporary error that results in multiple requests for the bearer token. Resolution for this is to ensure that API user rights are setup correctly and that target application is published with Google screening approval.
- Error Code 403: Forbidden. This error can be rather ambiguous and is produced if the request resources are not fully configured. A good example is if Google Analytics portal does not have correct Access Management or Property ID.
LogicModules in Package
The DataSources in this package do not include predefined datapoint thresholds (that is, no alerts will trigger based on collected data). This is because the technology owner has not provided KPIs that can be reliably extended to the majority of users. If you’d like to receive alerts for collected data, you’ll need to manually create custom thresholds, as discussed in Tuning Static Thresholds for Datapoints .