GA demystified

information about Google Analytics and its API.

Google Analytics (account, tracking and view IDs)


Administration page has 3 columns: ACCOUNT - PROPERTY - VIEW.

ACCOUNT (1st column)

account ID

| Account SettingsBasic SettingsAccount Id

PROPERTY (2nd column)

tracking ID

it’s displayed in both places:

| Property SettingsBasic SettingsTracking Id | Tracking InfoTracking CodeTracking ID

VIEW (3rd column)

view ID (profile ID)

| View SettingsBasic SettingsView ID

table ID

NOTE: not displayed in UI

API Manager (client IDs)


| Credentials (left sidebar) → CredentialsCredentials (tab)

OAuth 2.0 client IDs:

API keys:

pumba client IDs

NOTE: select pumba project (Re***) in top left menu beforehand (here you can also switch between projects targeted either for GA or GAW - this grouping is our own, not Google’s one).

pumba client IDs for all 3 stages (Development, Staging, Production) were created in finga*** account!

client ID for Development is stored in secrets.yml:

client IDs for Staging and Production are stored in chef.

pumba API keys

API keys are not used in pumba.

APIs Explorer

  1. - Query Explorer (almost the same as APIs Explorer but somewhat easier to use since it requires authorization and prefetches existing values - accounts, properties, views)

APIs Explorer allows to make API requests to different API services (optionally with OAuth 2.0 authorization) and exposes the same methods as those available in client libraries.

API services

all services available in APIs Explorer are listed here - select Google Analytics API v3 service.

API methods vs. HTTP requests

all methods for Google Analytics API v3 service are listed here.

these methods are exposed in client libraries for different languages and have language-specific interfaces to set query parameters.

API can also be queried as REST-ful endpoint by making HTTP request:

e.g. calling method with ids=ga:12345 argument (either in client library or APIs Explorer) is equivalent to making HTTP request (in fact this method has more required arguments than shown here).

when making HTTP request arguments can be supplied as:

methods currently used in pumba:

NOTE: in pumba we don’t use client libraries and make HTTP requests directly - methods are listed above for the sake of clarity only.


scopes are used to grant an application different levels of access to data on behalf of the end user. each API may declare one or more scopes.

Google Analytics API declares a set of scopes:

to get Google Analytics data it’s necessary to approve at least the last scope.

application and user authentication

APIs Explorer provides its own default credentials (client ID and client secret) when executing queries. or else it’s possible to provide custom credentials:

| Settings (icon in upper right corner) → Set API key / OAuth 2.0 Client IDCustom credentials

as a rule using default credentials must be sufficient as it’s all the same it’s necessary to grant access to application when OAuth 2.0 consent screen is displayed - it doesn’t matter whether this is pumba application or not.

to execute query it’s necessary to get access to user data - for this to happen user must authenticate himself (log in) and approve scopes application (either default one or pumba) is requesting.

NOTE: beware of the situation when user is already logged in (either in Chrome browser or via website) and this is a wrong user - log out in this case.

pumba accounts

in pumba user counters are accessed via these pumba accounts:

primary counters are created by users in their accounts and just shared with our re*** account. MCF counters are created by ourselves in re*** account (manually - not automatically in pumba).

consequently it’s necessary to log in one of pumba accounts (when Google account login screen is displayed) to get access to:

acquiring refresh and access tokens for application