smartchicago/foodborne — pull request #11 by cgansen (2013-03-28 21:29:07+00:00)
Title: WIP: Adding event tracking

This changeset adds support for Google Event Tracking

Google Analytics allows clients to track individual user actions: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#SettingUpEventTracking

This change adds a helper to make it simple to add tracking through out the application:

```
def ga_trackable(category, action, label, options = {})
# return data attributes for Google Analytics tracking

classes = options.delete(:class)
classes += " ga-trackable"
{
:'data-tracking-category' => category, :'data-tracking-action' => action,
:'data-tracking-label' => label, :'data-tracking-value' => options.delete(:tracking_value),
:class => classes
}.merge(options)
end
```

and in practice:

```
= s.button :submit, ga_trackable('Submission', 'Create', 'Public Submission', :class => "btn-success btn-large", :value => "Submit your report")
```

TODO:

- add tracking to admin UI