Integrating Metric Insights with Google Services

This article describes how to integrate with Google Services (BigQuery, Analytics, Calendar, Spreadsheet) in order to fetch their data into a Metric Insights' portal. 

To establish connectivity with Google Services, you need to configure an API Console Project and create a single Client ID that will serve as a basic identifier between any Google plugin and a Metric Insights instance. 

WORKFLOW:

  1. Build an API Project in the Google API Console
  2. Enable APIs for your Project
  3. Configure OAuth Consent Screen
  4. Get Authorization Credentials

PREREQUISITES:

How do I know if my Domain is verified?

To check whether your domain has been verified, follow this link Verify your domain with a TXT record

If Google informs you that your domain is authorized, proceed with the steps described below.

1. Build an API Project in Google API Console

 

  1. The API Console is where you enable and disable APIs, manage and view traffic data, and set up authentication. 
  2. project is a collection of settings, credentials, and metadata about the application or applications you are working on that make use of Google APIs and Google Cloud Platform resources.
Google APIs Console

Go to:  https://console.developers.google.com

Select the API project or create a new one

2. Enable APIs for your Project

 NOTE:

  1. Enabling an API associates it with the current project.
  2. The process of enabling an API varies depending on the API. Some APIs will prompt you to accept their Terms of Service before you can enable them.
  3. If you want to integrate several Google services with Metric Insights, you can enable the corresponding APIs from the API Library.
  1. Click Enable API at the top of the page. You will be redirected to the APIs Library
  2. Slect the required API and open its Product details. You can enable APIs for all supported services (BigQuery, Calendar, Spreadsheet, etc.) in this single Project
  3. Click [Enable]

The OAuth consent screen has to be configured before obtaining OAuth Client ID.

  1. Click [Configure Consent Screen]. You will be redirected to the Google Auth Platform
  2. Click [Get Started] and go through the steps to do the initial setup of OAuth consent screen

3.1. Select User Type

User Type defines the application's audience.

There are two User Types:

  • Internal: The application will be available only to users within the organization
  • External: Any user with Google Account will be able to each to the app

The chosen User Type can be checked in the Audience tab of Google Auth Platform.

For more information, check User Type.

3.2. Add Scopes

Scopes are permissions that are requested from users to allow your project to access specific types of private user data from their Google Account.

  1. Click [Add or Remove Scopes] to open the Update selected scopes pop-up window
  2. Non-sensitive scopes does not require Google verification
  3. Sensitive and restricted scopes require verification by Google if the chosen User Type is Public and have a sensitive indicator on the Google Cloud Console's OAuth consent screen configuration page
  4. Click to [Save] the changes

For more information about scopes, check OAuth 2.0 Scopes for Google APIs.

4. Get Authorization Credentials

Only one Google Project and one Web Client are required to establish connectivity to all supported Google services via plugins offered by Metric Insights.

Despite the fact that only one account (where the  API Console Project was created) serves for establishing connection between Google and Metric Insights, other Google accounts can be used to create Data Sources for Elements.

  1. Go to Credentials on the left side panel
  2. Click + Create Credentials and select OAuth client ID from the drop-down list

4.1. Configure a Web Client

Since your Web Client will be using OAuth 2.0 to access Google APIs, it must have authorization credentials that will serve as its identifiers to Google's OAuth 2.0 server.  

Client ID and Client secret are used to access the APIs that you have enabled for your project.

NOTE: Applications that use JavaScript to access Google APIs must specify authorized JavaScript origins. The origins identify the domains from which your application can send API requests.

  1. Application type: Select "Web Application" from the drop-down menu
  2. Name: Enter a meaningful name
  3. Authorized JavaScript Origins:  Enter the URL. Example: if the hostname is demo.metricinsights.com, the default is:
 https://demo.metricinsights.com 
  1. Authorized Redirect URIs: Enter path to callback value as /editor/service/validategoogleoauth2  Example: if the hostname is demo.metricinsights.com, the full value becomes:
 https://demo.metricinsights.com/editor/service/validategoogleoauth2 

5.    [Create]

NOTE: This value is referenced by Metric Insights at Admin > System > System Variables. Look for GOOGLE_OAUTH2_REDIRECT_URI in the list. System Variables are available to System Administrators only.

4.2. Use Client Credentials for Google Authentication

After Client ID and Secret Key are displayed, record these values to use for Google Authentication.

4.3. Authentication with a Google Service

To be able to source data from a Google Service, provide Authentication Values in the Connection Profile Parameters.

When creating a Connection Profile with a Google Service:

  1. Go to Plugin Data Sources Editor > Info tab
  2. Among the Required Parameters, specify Client ID and Client Secret