Skip to content

Commit

Permalink
modularized controller, easier to read and overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Reinsch committed Oct 13, 2011
1 parent aec6197 commit cb17071
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/controllers/garails/google_analytics_controller.rb
Expand Up @@ -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" }
Expand All @@ -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 => '/'}
Expand Down

0 comments on commit cb17071

Please sign in to comment.