Question

I was wondering if there was an adapter library for Javascript to make integrating tools like Google Analytics, Kissmetrics, mixpanel, Chartbeat, gaug.es, etc easier. Something like SLF4J, but for event tracking. We are evaluating different tools, and it seems like it would be useful if it was possible to quickly swap between them.

Was it helpful?

Solution

We recently built analytics.js to solve this problem. It's a javascript wrapper library for Google Analytics, KISSmetrics, Mixpanel, Gauges, Chartbeat, GoSquared, and 16 other services.

The library does pretty much everything you mentioned:

  • Loads all the javascript snippets asynchronously
  • Abstracts the event-views and other API methods across all the libraries
  • And exposes each service's global object in case you need to do something custom

You can check out the open source library on Github: http://segmentio.github.com/analytics.js

Or for an easier solution that also supports the same abstraction on the server-side for Python, Ruby, Node, Java and .NET, check out https://segment.io

OTHER TIPS

It turns out there is a library that does much of what I was looking for, known as Gatling.

It greatly simplifies tracking multiple analytics libraries at once, all asynchronously. In addition, you can even expose your GA 'gat' object for triggering page views and events manually.

It doesn't seem to use the Google Analytics 'gaq' object, and it doesn't abstract event-views across multiple libraries, which I think would be useful features, but it is pretty close to what I was looking for.

This area is sometimes called "Universal Tag" or "Tag Management" - the last time I looked there was a handful of big-ticket vendors, like Tealium, BrightTag & Tagman, but not much in the open source world.

In mid-2011, QuiBit (qubitproducts.com) launched their open-source OpenTag, but this seems to be an open/closed play, where the on-page javascript is open-source, but it is powered by their proprietary management system which does the tag injection - while they don't display terms & pricing on their site, I seem to recall they had a sizeable no-contract, no-pay starting band, which maybe you could use while you work out which solution(s) is best, then embed them directly before production ramps up to the paying levels of traffic.

I'm not sure there could be such a standard container, because every site has very specific needs in term of tracking (since features and usage are often unique). But you could do the following:

  • design precisely the data model of what you want to track and build JavaScript objects or an API exposing it to the tracking code
  • design event handlers for every interaction / transaction you want to track
  • use a sort of plug-in system to map each tracking action to the core language of each tracking provider
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top