module Satellite::Controllers::GoogleAnalyticsController
Public Instance Methods
tracker()
click to toggle source
# File lib/satellite/controllers/google_analytics.rb, line 5 def tracker @tracker ||= Satellite.create_tracker(:google_analytics, ga_params) end
Protected Instance Methods
ga_params()
click to toggle source
# File lib/satellite/controllers/google_analytics.rb, line 15 def ga_params # domain specific stuff domain_name = (request.env["SERVER_NAME"].nil? || request.env["SERVER_NAME"].blank?) ? "" : request.env["SERVER_NAME"] referral = request.env['HTTP_REFERER'] || '' path = request.env["REQUEST_URI"] || '' # Capture the first three octects of the IP address and replace the forth # with 0, e.g. 124.455.3.123 becomes 124.455.3.0 remote_address = request.env["REMOTE_ADDR"].to_s ip = (remote_address.nil? || remote_address.blank?) ? '' : remote_address.gsub!(/([^.]+\.[^.]+\.[^.]+\.)[^.]+/, "\\1") + "0" visitor_uuid = Digest::MD5.hexdigest(ga_visitor_id) { :utmhn => domain_name, :utmr => referral, :utmp => path, :utmip => ip, :utmvid => visitor_uuid } end
ga_visitor_id()
click to toggle source
# File lib/satellite/controllers/google_analytics.rb, line 11 def ga_visitor_id "#{request.env["HTTP_USER_AGENT"]}#{rand(0x7fffffff).to_s}" end