Complete package to use google analytics in your rails application. It supports recording to google analytics:
for mobile handsets (gif)
Add to your Gemfile:
and run 'bundle install'.
Then create a config/initializers/garails.rb with the following content:
Garails.ga_account = 'UA-12345678-9' # Garails.ga_cookie_domain = '.mydomain.com' # Garails.ga_hostname = 'www.mydomain.com'
Add to your layout (usually app/views/layouts/application.html.erb) in the head section:
<%= utm_tag %>
In your view or controller you can record events by using:
ga_event(category, action, label, value)
See code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html for details. label and value are optional.