IBM Digital Analytics, formerly Coremetrics, provides an API for you to retrieve reports or data from the analytics platform. You can use it to extract data from your reports to build your own in-house reports or widgets to display web analytics data on your intranet.

To access data via the API you need to generate an API URL; your report data is accessed over HTTP.  You create these URLs in the Manage section of Digital Analytics.  The output can be in various formats: csv, xls, json, and xml.  You specify a date range for the report data you require, and once you have an API URL you can alter the date range (and output format) each time you make a request.

This blog post will demonstrate how to generate an API URL and how to access it programmatically.

Generating an API URL

To access the API wizard you need to log into IBM Digital Analytics and go to the Manage -> API option in the left hand menu.

Generate Digital Analytics Report API

You will need to choose the report category, the report you wish to retrieve (which can be a default report view or one you have customised), the format you require and a date range.  Then click ‘Generate API’ and the report URL will appear in the field at the bottom of the dialog.  Save this URL for use later.

Note that the URL contains a query string with various name/value pairs containing your client id, username, authentication token, report id, format and date.  The format and date can be changed as you wish whenever you make a request for this data.

Using the API

The use cases for utilising the API range from a simple requirement to automate the access of a report in a specific format, accessing report data to do some further calculations or for integration of web analytics data into your on-premise data warehouse.

A customer came to me with the requirement to get analytics data from Coremetrics at a 5 min interval so they could measure the online impact of offline advertising, namely, TV advertising. They wanted to analyse this data in-house and provide it to their agency. By default you cannot get this level of granularity from the standard reports, and while you can get this data from Monitor you cannot download it.  The solution was to make use of the API and to automate the API request every 5 minutes using some python code. The implementation steps were as follows:

  • Create a Top Level Metrics view containing only the metrics they required: page views, sessions, new sessions etc.
  • Generate an API URL for the report.
  • Write python code to request the API URL and grab the metrics.  Output the metrics into a csv file.
  • The CSV file could then be supplied to their agency and loaded in excel for trending and analysis.

Here is an extract of the python code I wrote to request the API URL and parse the json data:

Digital Analytics API Python code

The output of the python script is a csv file containing web analytics data, for example sessions or visits at 5 minute intervals.

5min Digital Analytics Data

The customer then overlayed the timings of the TV adverts to assess the online impact of those adverts in terms of increased visitors and visits.

The API available in Coremetrics allows you extend the reporting capabilities available in the analytics platform to bring data in-house for further integration or analysis.  It is a powerful and flexible method for web analytics data access that allows you to automate access and manipulate the data for your requirements.