The Google Analytics Data Import module

Content

Google Analytics
Working with the Google Analytics Reporting API
The panel for specifying a Google Analytics data source


Google Analytics

Google Analytics (see http://www.google.com/analytics/) is a mechanism for tracking the usage statistics and typical browsing paths of web sites and web shops offered by Google Inc.. The basic service is free, only high-volume usage is charged.

Two actions must be taken in order to use Google Analytics for a web site. First, on http://www.google.com/analytics/ an account must be created in which the domains and sub-domains to be tracked are specified. Second, each web page whose usage is to be tracked must be equipped with a little script which sends tracking information to the Google Analytics database each time the web page is opened. An explanation and step-by-step instructions can be found at http://www.google.com/analytics/discover_analytics.html.

Within a Google Analytics account one can define one or more 'web properties' and within each web property one or more 'profiles'. A web property can be regarded as a group of interrelated analytics tasks and each profile as one single analytics task. By inserting the little tracking scripts into the single web pages one defines which web page will send usage information to which profile.

For Evaluating the collected results, Google Analytics provides both a browser-based graphical frontend and an application programming interface (API) via which the collected data of a profile can be read into a third party program. This API is used by Synop Analyzer for reading the Google Analytics data of a web site into the software and for interactively exploring them.


Reading data via the Google Analytics Reporting API

In order to be able to access a web site's collected Google Analytics data, the owner of the Google Analytics account has to make sure the Analytics API service is enabled. To that purpose, log into the API administration console https://code.google.com/apis/console/, click on the menu item Services and switch the status of the service Analytics API to 'ON'.

image file img/googleAPI_analyticsAPI_830.png not found

Next, you have to create at least one access client within the API administration console. A client is a predefined access path for external programs which grants access to the collected data of one or more profiles within a Google analytics account.

To create a new access client, click on the menu item API Access within this administration console. This opens up a screen view in which pressing the button Create Client ID creates a new access client consisting of a client ID, a password called 'client secret' and a 'redirect URL'.

image file img/googleAPI_clientID_859.png not found

When you later try to connect to the Google Analytics API, you must have these three values (client ID, client secret and redirect URL) at hand.

In addition, you must specify the 8-digit ID of one of the predefined profiles within the Google Analytics account. You can step through all available profile IDs by logging into your accoutn at https://www.google.com/analytics/web/ and by then clicking on the menu item on the upper left corner of the screen. This menu item opens a drop-down list of all profiles within the active Google Analytics account. A mouse-click on one of the rows of this drow-down list makes the account ID, web property ID and profile ID of that entry appear in the URL address line in your web browser. The profile ID is the series of 8 digits at the very end of the displayed URL, right after the letter 'p'.

image file img/googleAPI_profileID_765.png not found

These 8 digits (in the picture below they start with 55...) must also be at hand when you try to read Google Analytics data from Synop Analyzer.


The panel for specifying a Google Analytics data source

From Synop Analyzer, you access a Google Analytics data source by clicking File → Import data from Google Analytics API. This action opens up a bew panel in which the previously described values of client ID, client secret and profile ID can be entered.

image file img/googleAPI_profileID.png not found

In the panel fields Dimensions to be read from Google Analytics API and Metrics to be read from Google Analytics API you specify which types of information, that means which data fields the retrieved data table will have. Each single dimension and each metrics has to be entered in the form of ga:[Name]. A list of all supported dimension and metrics name can be found at http://code.google.com/intl/de-DE/apis/analytics/docs/gdata/dimsmets/dimsmets.html. The specifications performed in the screenshot above specify that the retrieved data has the four columns ga:source (web domain, from which the visitor came to our tracked web site), ga:medium (type of the web site from which the visitor came to our web site), ga:visits (number of visits to our tracked web site) and ga:pageviews (number of clicked web pages).

You can memorize frequently used client IDs, client secrets, profile IDs, active dimensions and active metrics in the preference settings at Preferences → Data Import Preferences. Then you do not have to type in these values manually each time you open the Google API sepecification panel.

And one more step has to be done befor the data transfer can succeede: an authorization code must be created and entered into the last input field of Synop Analyzer's Google Analytics API specification panel. You generate an authorization code by pressing the button Read and Store data in the panel, by accepting the security question in the browser window which pops up and by copying the displayed code into the Synop Analyzer panel.

Once all input fields of the panel have been filled correcty, pressing the button Read and store data the data retrieval process. The data are first saved to a local file named ga[ProfileID]_[currentDa te].txt in the crrent working directory; afterwards, they are read into a data source tab on the left side of the Synop Analyzer workbench just as any other input data source.

Note that the authorization code is not reusable: you have to create and fill in a new authorization code each time you want to read data from the API.