Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doorkeeper/garails
Google Analytics for Rails
https://github.com/doorkeeper/garails
Last synced: about 2 months ago
JSON representation
Google Analytics for Rails
- Host: GitHub
- URL: https://github.com/doorkeeper/garails
- Owner: doorkeeper
- License: mit
- Fork: true (mreinsch/garails)
- Created: 2011-04-12T01:24:47.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2021-08-13T06:14:33.000Z (about 3 years ago)
- Last Synced: 2024-05-16T04:55:13.493Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 38.1 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE.txt
Awesome Lists containing this 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:
My App
...
<%= google_analytics_tracking_javascript %>
...=== 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 http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html for details. label and value are optional.