Tuesday, April 21, 2015

Google Analytics Plugins and Tasks APIs

English: Histogram of sepal widths for Iris ve...
The Google developer's documentation says that to reduce the size and loading times of the analytics.js library, it is constructed using a modular architecture. Different plugins need to be loaded to add support a number of features.

Some interesting aspects of this architecture is that analytics has to collect timing information as well as reporting of data as it is loading. In the background analytics uses a bit bucket algorithm to regulate  reporting impact to both the producer (browser) and consumer (their cloud).

These plugins are introduced using the require directive. Some examples of plugins are
  • e-commerce plugin - 'ecommerce
  • enhanced e-commerce plugin - 'ec'
  • enhanced link attribution plugin - 'linkid'
  • cross domain auto link plugin - 'linker'
  • display features plugin - 'displayfeatures
Recently Google introduced the plugin api in which it introduced documentation on how to extend analytics using your own plugins. They provide a small example showing how UTM parameters in the query string are processed in analytics.

Medium Tank M4 Sherman "Catherine" d...
A second piece of the puzzle is the Tasks API. This provides the ability to modify much of the low level behavior taking place during reporting. Tasks can easily be used to regulate different sampling rates for registered v.s. unregistered users or to send a copy of analytics reporting to a local storage within the enterprise.

My own speculation is that now that facebook's is providing better advertising google is under pressure to improve analytics to provide greater value with its other advertising product ecosystem . By opening up these api's analytics consultants as well as google own professionals support staff to will now have greater incentives to  collaborate in an open source form and extend analytics functionality to many areas where universal analytics is weak. Secondly these APIs can be used from tag manager to unify the deployment of analytics in different settings and on different devices with reduced involvement of IT departments.

The main annoyance is that the above plugins as well as the core analytics library as well as its debug version are not provides in  unminified version together with code comments. This will greatly reduce the level of code being written and is of small impediment to a competitor curious about what is going on in there.