Browse files

event helper

  • Loading branch information...
1 parent 114e216 commit 66264a41d08d6e5491b18bb94d5a09024d1383d7 @mreinsch committed Dec 27, 2010
Showing with 22 additions and 6 deletions.
  1. +3 −3 Gemfile.lock
  2. +6 −0 README.rdoc
  3. +7 −0 app/helpers/garails/event_helper.rb
  4. +1 −1 garails.gemspec
  5. +5 −2 lib/garails/engine.rb
View
6 Gemfile.lock
@@ -2,7 +2,7 @@ PATH
remote: .
specs:
garails (0.0.2)
- gabbara (~> 0.0.2)
+ gabbara (~> 0.0.4)
GEM
remote: http://rubygems.org/
@@ -38,7 +38,7 @@ GEM
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
- gabbara (0.0.2)
+ gabbara (0.0.4)
activesupport
i18n (0.5.0)
mail (2.2.12)
@@ -77,7 +77,7 @@ PLATFORMS
ruby
DEPENDENCIES
- gabbara (~> 0.0.2)
+ gabbara (~> 0.0.4)
garails!
rails (~> 3.0.3)
shoulda
View
6 README.rdoc
@@ -44,3 +44,9 @@ In your layout for mobile handsets without Javascript support, add at the very b
=== 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.
+
View
7 app/helpers/garails/event_helper.rb
@@ -0,0 +1,7 @@
+module Garails::EventHelper
+ def ga_event(category, action, label = nil, value = nil)
+ return unless Garails.ga_setup?
+ g = Garails.gabba(request)
+ g.event(category, action, label, value)
+ end
+end
View
2 garails.gemspec
@@ -17,5 +17,5 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
- s.add_dependency("gabbara", "~> 0.0.2")
+ s.add_dependency("gabbara", "~> 0.0.4")
end
View
7 lib/garails/engine.rb
@@ -1,7 +1,10 @@
module Garails
class Engine < ::Rails::Engine
- initializer 'garails.mobile.helper' do |app|
- ActionController::Base.helper Garails::MobileHelper, Garails::JavascriptHelper
+ initializer 'garails.view.helper' do |app|
+ ActionController::Base.helper Garails::MobileHelper, Garails::JavascriptHelper, Garails::EventHelper
+ end
+ initializer 'garails.controller.helper' do |app|
+ ActionController::Base.send :include, Garails::EventHelper
end
end
end

0 comments on commit 66264a4

Please sign in to comment.