Unify Logo Footer.svg
Unify Integrations
Logo
Google Analytics

Google Analytics

Logo

4 mins READ

Google Analytics is Google's service for measuring website and app traffic and engagement, organized into accounts and properties. The UnifyApps Google Analytics connector uses the Google Analytics Data API to run reports on a Google Analytics property, with the dimensions, metrics, date ranges and filters you choose, from workflows.

This guide covers every authentication type available on the connection form, and the actions supported, along with the Google Analytics scope each one needs.

Authentication

Before you begin, you should have the following information:

  • Connection name: a descriptive name such as MyAppGoogleAnalyticsIntegration, so the connection is easy to identify later.

  • Authentication type: select the type of authentication for connecting to your Google Analytics account:

    1. Service Account

    2. Single Sign-On(SSO)

  • Property ID: the numeric ID of the Google Analytics property to report on. It is required for every authentication type.

To find the Property ID, open Google Analytics, click Admin, select the property and open Property Settings. The numeric Property ID is shown there, for example 123456789.

Both authentication types request the scopes https://www.googleapis.com/auth/analytics.readonly and https://www.googleapis.com/auth/analytics automatically. There is no Scopes field on the form.

1. Service Account

Use this when a service account should act on behalf of a user in your Google Workspace domain through domain-wide delegation, so no user has to sign in.

Step 1: Create a service account in Google Cloud

  1. In the Google Cloud Console, select or create a project, and enable the Google Analytics Data API under APIs & Services → Library.

  2. Go to IAM & Admin → Service Accounts and click Create service account. Enter a name and click Done.

  3. Open the service account and copy its Email. Click Show advanced settings and, under Domain-wide delegation, copy the Client ID used in the next step.

  4. Go to the Keys tab → Add key → Create new key, choose JSON and click Create. The downloaded file holds the client_email and private_key. Store it securely.

google-analytics-screenshot-1.png
google-analytics-screenshot-1.png

Step 2: Give the service account domain-wide access

  1. A Google Workspace super administrator opens the Admin console → Security → Access and data control → API controls.

  2. Click Manage Domain Wide Delegation → Add new.

  3. Enter the service account's client ID, add the scopes https://www.googleapis.com/auth/analytics.readonly and https://www.googleapis.com/auth/analytics, separated by commas, and click Authorize. See Control API access with domain-wide delegation for details.

Note: the connection reads data as the user you enter in User email. That user must belong to the Workspace domain where domain-wide delegation was granted and must have at least the Viewer role on the Google Analytics property (in Google Analytics, Admin → Property → Access management). Google says delegation changes can take up to 24 hours to apply.

Step 3: Create the connection in UnifyApps

  1. Open Connections → New Connection → Google Analytics and enter a Connection name.

  2. Select Service Account as the Authentication type.

  3. Enter the Property ID.

  4. Enter the Service account email (the client_email from the JSON key file).

  5. Enter the User email of the Workspace user the service account acts as.

  6. Paste the Private key (the private_key from the JSON key file).

  7. Click Test Connection to validate the credentials, then click Create.

2. Single Sign-On(SSO)

Use this when you want to connect with your own Google account and do not need to create a Google Cloud app.

  1. Enter a Connection name.

  2. Select Single Sign-On(SSO) as the Authentication type.

  3. Enter the Property ID.

  4. Click Authorize. You are redirected to the Google sign-in page.

  5. Sign in with a Google account that has at least the Viewer role on the property.

  6. Review the permissions on the consent screen and click Allow.

  7. You are redirected back to UnifyApps with a confirmation that the account is connected.

Actions

Scopes are shown in short form: analytics.readonly means https://www.googleapis.com/auth/analytics.readonly. The connection already requests both Analytics scopes.

Actions

Description

Scopes Required

Get report

Returns the analytics data for a report from Google Analytics.

analytics.readonly (or analytics)