batmanjs/batman — pull request #835 by SoapyIllusions (2013-09-29 02:08:19+00:00)
Title: Added data-track binding to Batman core

This PR integrates @pushrax's work on the `data-track` binding into Batman core. It removes it's dependency on Google Analytics and instead allows for any analytics service to be plugged in.

Whenever an event is fired, Batman will call `track(type, data)` on a singleton instance of `Batman.currentApp.EventTracker`.

It provides two bindings

1. `data-track-click="keypath"`, will call the EventTracker with `('click', view.get('keypath'))` when the node is clicked.
2. `data-track-view="keypath"`, will call the EventTracker with `('view', view.get('keypath'))` when the node is rendered.

And here is an example of a Google Analytics back end would:

```coffee
class Shopify.EventTracker
track: (type, data) ->
switch type
when 'click' then _gaq?.push(['_trackEvent', data.category, data.label])
when 'view' then _gaq?.push(['_trackPageview', window.location.href])
```

/cc @pushrax @jbruton @nickjs