Search code examples
javascriptgoogle-analyticsanalyticsweb-analytics-tools

Is there a Event Analytics Abstraction Layer for Javascript?


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.


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