Permalink
Browse files

modularized controller, easier to read and overwrite

  • Loading branch information...
1 parent aec6197 commit cb170719c931cc4ac2add78b9f7f05b948dfe680 @mreinsch mreinsch committed Oct 13, 2011
Showing with 9 additions and 4 deletions.
  1. +9 −4 app/controllers/garails/google_analytics_controller.rb
@@ -17,10 +17,7 @@ class Garails::GoogleAnalyticsController < ActionController::Base
UTM_COOKIE_NAME = "__utmmobile"
def utm
- if Garails.ga_setup?
- g = Garails.mobile_gabba(request, :utmn => params[:utmn], :utmcc => "__utma=999.999.999.999.999.1;", :utmhid => "")
- g.page_view('', :utmvid => @visitor_id)
- end
+ record_access if Garails.ga_setup?
response.headers.merge(UTM_HEADERS)
respond_to do |format|
format.gif { send_data UTM_GIF_DATA, :type => :gif, :disposition => "inline" }
@@ -29,6 +26,14 @@ def utm
private
+ def record_access
+ mobile_gabba.page_view('', :utmvid => @visitor_id)
+ end
+
+ def mobile_gabba
+ Garails.mobile_gabba(request, :utmn => params[:utmn], :utmcc => "__utma=999.999.999.999.999.1;", :utmhid => "")
+ end
+
def extract_visitor_id
@visitor_id = cookies[UTM_COOKIE_NAME] || construct_new_visitor_id
cookie_data = {:value => @visitor_id, :expires => Time.now + 2.years, :path => '/'}

0 comments on commit cb17071

Please sign in to comment.