Google Analytics

The Integrator natively supports Google Analytics reporting API.

When configuring Google Analytics connector you must point it to the particular web site, defined by the web property View ID, and authorize it to use with this web property.

What is a web property?

Web property is a collections of web sites under the same Google Analytics account.

What is a web property View ID?

Web property View ID is a unique id of the particular web site, for example google.com, under Google Analytics account.

When configuring Google Analytics connector, you must specify web property View ID.

You can find your web property View ID in the Google Analytics Admin.

Step 1 - login into Google Analytics console.

Google Analytics Console

Step 2 - select web property.

Web Property

Step 3 - click on a property name drop down on the top of the screen.

Look for a number of the left, below property name. This is your web property View ID.

Google Analytics View ID

What is a service account?

You need a service account in order to access Google Analytics API. Service account is an account that belongs to the application, such as Integrator, instead of to an individual end user. Application calls Google APIs on behalf of the service account, so users aren't directly involved. This scenario is sometimes called "two-legged OAuth," or "2LO." (The related term "three-legged OAuth" refers to scenarios in which your application calls Google APIs on behalf of end users, and in which user consent is sometimes required.)

Important: service account is not the same as account used to login to the Google Analytics console from the web browser.

Read more about Google Service accounts.

Important: Integrator already has a service account which can be used to access Google Analytics API. This account is linked to the email address etl-framework@api-project-201080624425.iam.gserviceaccount.com. You can create you own account (see step-by-step instruction below) and use it instead of default.

What is a service account email?

Each service account has unique email address automatically assigned by Google when account is created.

Loosely you can call a service account email a user name, and service account - a password.

Why when I create a new connection to the Google Analytics the "service account email" is populated and "service account" is empty?

Integrator already includes a service account, linked to the email etl-framework@api-project-201080624425.iam.gserviceaccount.com. The actual service account field is empty because information about account, such a private key, etc. is stored in the secure storage and not available to end user.

Important: when service account field is empty Integrator will always use a default service account, linked to the email etl-framework@api-project-201080624425.iam.gserviceaccount.com, regardless of what you entered in the service account email field.

Default service account.

Integrator comes with a default service account, which belongs to Etlworks. This account is linked to the email address etl-framework@api-project-201080624425.iam.gserviceaccount.com. It is recommend to use this account whenever possible.

I'm using the same email I use to login to the Google Analytics console as my "service account email". Why Google Analytics connector cannot connect?

Because you must use service account email automatically assigned by Google when you created a new service account. This email is not the same as you regular email used to login to the Google Analytics console.

Once again, the default service account email is etl-framework@api-project-201080624425.iam.gserviceaccount.com and all you need to do is authorize to use with a web site you are trying to get analytics data for.

Creating new service account.

If needed, you can create a new service account. You might do this is you don't want to use a default account, for example for security purposes.

Step 1. You must have active Google account.

Step 2. Using this account open setup tool

Step 3. Click Create a project and select API Project.

Step 4. Click Go to credentials

Step 5. Select the following parameters:

Service account credentials

Step 6. Click What credentials do I need

Step 7. Enter Service account name and click Continue.

Step 8. The account will be created, and the json file with account details will be downloaded to your local hard drive. Important: please keep it in a safe place, we will need it later.

The downloaded json will look like the one below:

{
  "type": "service_account",
  "project_id": "id",
  "private_key_id": "key_id",
  "private_key": "-----BEGIN PRIVATE KEY-----\key\n-----END PRIVATE KEY-----\n",
  "client_email": "service account email",
  "client_id": "client id",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/etl-framework%40service-account@email"
}

The important part is a service account email.

Authorizing service account for the web property.

Before Google Analytics connector can access the web property, the service account must be authorized.

Open Google Analytics Admin in a web browser and under User Management add permission for service account email.

Authorize service account for Google Analytics

Creating Google Analytics flows

Important: before you start creating flows you must:

  1. Get a web property View ID.
  2. Use default service account (recommended), or create a new service account if needed.
  3. Authorize service account for the web property.

Once 1-3 are completed you can start creating flows which extract data from the Google Analytics.

Step 1 Create Google Analytics Connection.

Google Analytics Connection

When creating a connection, define the following properties:

Step 2 Start creating a flow by opening Flow Builder window, clicking the + button and typing in Google Analytics in the search box:

Google Analytics Flows

Step 3 Continue by defining a transformation(s) where source (FROM) is a Google Analytics Connection created in a step 1, and a destination (TO) is a ether file, database or a web service.

Google Analytics to CSV flows

Step 4 Add mapping and parameters if needed.