An API can be considered a channel to tap into a ‘black box’ resource with a set of defined specifications. It is the responsibility of the API implementer to ensure that the black box behaves as specified, as long as all required parameters are provided. This then allows users to benefit from the services and solutions offered by any such black box resource without the need to implement, in many cases, costly solutions and maintaining them. The user is merely required to provide essential parameters for each request and the information or solution is provided by the black box as specified.
Google Analytics APIs One such implementation is done by Google for use by Google Analytics users. This implementation consists of, currently, two APIs for users/developers to go beyond what the standard Google Analytics interface provides.
Fig 1. Life-cycle of Google Analytics API request.
- The Management API With Google Analytics APIs, client applications can request statistical data from Google Analytics profiles for authorised users and also refine the results by using query parameters. As shown in Figure 1 above, the process starts with your application authorising the access credentials – the Management API supports three authentication protocols: ClientLogin, AuthSub and OAuth. On successful authentication, your application selects a Google Analytics account or a profile to read the data from. A user may have access to multiple accounts and each account may contain various profiles; Google Analytics needs to know the section from which to retrieve the data. The final step this API performs before handing the control over to the Data Export API is to request the data from the selected section of Google Analytics.
- The Data Export API
The core of the Data Export API consists of a Data Feed Request which is organised in various categories: visitors, traffic sources, content, internal site search, goals and ecommerce. Each report uses a combination of metrics and dimensions to describe key statistics of the associated online activity. The API provides a basic set of return error codes for in-application exception handling. On successful data retrieval, your application can manipulate the data in a variety of ways:
- to report in general on a site/application,
- to further compute the data collected, or
- to answer a specific analytics question.
In spite of Google Analytics’ shortcomings when it comes to analytics of large online solutions – and assuming it is only going to improve now that the next version is coming out – making effective use of APIs can extend the functionality of any application in need of crunching analytics data. These APIs extend the flexibility of Google Analytics to meet most analytics needs, to give you access to analytics information within your application without any need to import data or copy and paste from Excel. In my opinion there is potential to make use of these APIs in larger situations to provide reporting and analytics data built into a large scale host application.