Project

garails

0.0
Low commit activity in last 3 years
No release in over a year
Google Analytics for Rails
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 4.0.0
 Project Readme

Google Analytics for Rails¶ ↑

Complete package to use google analytics in your rails application. It supports recording to google analytics:

  • for normal web browsers (javascript)

  • for mobile handsets (gif)

  • programmatically (events)

Installation¶ ↑

Add to your Gemfile:

gem 'garails'

and run ‘bundle install’.

Then create a config/initializers/garails.rb with the following content:

Garails.ga_account = 'UA-12345678-9'

Usage¶ ↑

for normal web browsers¶ ↑

Add to your layout (usually app/views/layouts/application.html.erb) in the head section:

<html>
  <head>
    <title>My App</title>
    ...
    <%= google_analytics_tracking_javascript %>
  </head>
  <body>
  ...

for mobile handsets (non-Javascript)¶ ↑

In your layout for mobile handsets without Javascript support, add at the very bottom of the body the following:

<%= utm_tag %>

programmatically¶ ↑

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.