Class: AnalyticsGoo::GoogleAnalyticsAdapter
- Inherits:
-
Object
- Object
- AnalyticsGoo::GoogleAnalyticsAdapter
- Defined in:
- lib/analytics_goo/google_analytics_adapter.rb
Constant Summary collapse
- GA_DOMAIN =
'www.google-analytics.com'
- GA_IMAGE =
'__utm.gif'
Instance Attribute Summary collapse
-
#analytics_id ⇒ Object
Returns the value of attribute analytics_id.
-
#browser_language ⇒ Object
Returns the value of attribute browser_language.
-
#campaign ⇒ Object
Returns the value of attribute campaign.
-
#content ⇒ Object
Returns the value of attribute content.
-
#cookie_values ⇒ Object
Returns the value of attribute cookie_values.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#env ⇒ Object
Returns the value of attribute env.
-
#http_accept_language ⇒ Object
Returns the value of attribute http_accept_language.
-
#java_enabled ⇒ Object
Returns the value of attribute java_enabled.
-
#language_encoding ⇒ Object
Returns the value of attribute language_encoding.
-
#medium ⇒ Object
Returns the value of attribute medium.
-
#new_campaign_session ⇒ Object
Returns the value of attribute new_campaign_session.
-
#noop ⇒ Object
Returns the value of attribute noop.
-
#page_title ⇒ Object
Returns the value of attribute page_title.
-
#referrer ⇒ Object
Returns the value of attribute referrer.
-
#remote_address ⇒ Object
Returns the value of attribute remote_address.
-
#repeat_campaign_visit ⇒ Object
Returns the value of attribute repeat_campaign_visit.
-
#screen_color_depth ⇒ Object
Returns the value of attribute screen_color_depth.
-
#screen_resolution ⇒ Object
Returns the value of attribute screen_resolution.
-
#source ⇒ Object
Returns the value of attribute source.
-
#term ⇒ Object
Returns the value of attribute term.
-
#tracking_code_version ⇒ Object
Returns the value of attribute tracking_code_version.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize(ac) ⇒ GoogleAnalyticsAdapter
constructor
A new instance of GoogleAnalyticsAdapter.
-
#track_page_view(path) ⇒ Object
send a request to get the image from google.
- #urchin_url(ssl = false) ⇒ Object
- #utm_campaign ⇒ Object
- #utm_content ⇒ Object
- #utm_medium ⇒ Object
- #utm_source ⇒ Object
- #utm_term ⇒ Object
-
#utmac ⇒ Object
utmac Account String.
-
#utmcc ⇒ Object
utmcc Cookie values.
-
#utmcn ⇒ Object
utmcn Starts a new campaign session.
-
#utmcr ⇒ Object
utmcr Indicates a repeat campaign visit.
-
#utmcs ⇒ Object
utmcs Language encoding for the browser.
- #utmdt ⇒ Object
-
#utmhn ⇒ Object
utmhn Host Name, which is a URL-encoded string.
-
#utmip ⇒ Object
utmip Remote IP address.
-
#utmje ⇒ Object
utmje Indicates if browser is Java-enabled.
-
#utmn ⇒ Object
utmn Unique ID generated for each GIF request to prevent caching of the GIF image.
-
#utmr ⇒ Object
utmr Referral, complete URL.
-
#utmsc ⇒ Object
utmsc Screen color depth utmsc=24-bit.
-
#utmsr ⇒ Object
utmsr Screen resolution utmsr=2400x1920&.
-
#utmul ⇒ Object
utmul Browser language.
-
#utmwv ⇒ Object
utmwv Tracking code version utmwv=1.
Constructor Details
#initialize(ac) ⇒ GoogleAnalyticsAdapter
Returns a new instance of GoogleAnalyticsAdapter.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 72 def initialize(ac) # sets the environment that this should be run in @analytics_id = ac[:analytics_id] @domain = ac[:domain] @env = ac[:environment] @noop = ac[:noop] || false @page_title = ac[:page_title] || '' @referrer = ac[:referrer] || '-' @remote_address = ac[:remote_address] @user_agent = ac[:user_agent] || '' @http_accept_language = ac[:http_accept_language] || '' @campaign = ac[:campaign] || '' @source = ac[:source] || '' @medium = ac[:medium] || '' @term = ac[:term] || '' @content = ac[:content] || '' @language_encoding = ac[:language_encoding] || 'UTF-8' @java_enabled = ac[:java_enabled] || '1' @screen_color_depth = ac[:screen_color_depth] || '0-bit' @screen_resolution = ac[:screen_resolution] || '0x0' @browser_language = ac[:browser_language] || 'en-us' @tracking_code_version = ac[:tracking_code_version] || '4.4sj' @new_campaign_session = ac[:new_campaign_session] || '1' @repeat_campaign_visit = ac[:repeat_campaign_visit] || '1' @cookie_values = ac[:cookie_values] || '__utma%3D999.999.999.999.999.1%3B' end |
Instance Attribute Details
#analytics_id ⇒ Object
Returns the value of attribute analytics_id.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def analytics_id @analytics_id end |
#browser_language ⇒ Object
Returns the value of attribute browser_language.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def browser_language @browser_language end |
#campaign ⇒ Object
Returns the value of attribute campaign.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def campaign @campaign end |
#content ⇒ Object
Returns the value of attribute content.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def content @content end |
#cookie_values ⇒ Object
Returns the value of attribute cookie_values.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def @cookie_values end |
#domain ⇒ Object
Returns the value of attribute domain.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def domain @domain end |
#env ⇒ Object
Returns the value of attribute env.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def env @env end |
#http_accept_language ⇒ Object
Returns the value of attribute http_accept_language.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def http_accept_language @http_accept_language end |
#java_enabled ⇒ Object
Returns the value of attribute java_enabled.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def java_enabled @java_enabled end |
#language_encoding ⇒ Object
Returns the value of attribute language_encoding.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def language_encoding @language_encoding end |
#medium ⇒ Object
Returns the value of attribute medium.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def medium @medium end |
#new_campaign_session ⇒ Object
Returns the value of attribute new_campaign_session.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def new_campaign_session @new_campaign_session end |
#noop ⇒ Object
Returns the value of attribute noop.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def noop @noop end |
#page_title ⇒ Object
Returns the value of attribute page_title.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def page_title @page_title end |
#referrer ⇒ Object
Returns the value of attribute referrer.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def referrer @referrer end |
#remote_address ⇒ Object
Returns the value of attribute remote_address.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def remote_address @remote_address end |
#repeat_campaign_visit ⇒ Object
Returns the value of attribute repeat_campaign_visit.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def repeat_campaign_visit @repeat_campaign_visit end |
#screen_color_depth ⇒ Object
Returns the value of attribute screen_color_depth.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def screen_color_depth @screen_color_depth end |
#screen_resolution ⇒ Object
Returns the value of attribute screen_resolution.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def screen_resolution @screen_resolution end |
#source ⇒ Object
Returns the value of attribute source.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def source @source end |
#term ⇒ Object
Returns the value of attribute term.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def term @term end |
#tracking_code_version ⇒ Object
Returns the value of attribute tracking_code_version.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def tracking_code_version @tracking_code_version end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
65 66 67 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 65 def user_agent @user_agent end |
Instance Method Details
#track_page_view(path) ⇒ Object
send a request to get the image from google
231 232 233 234 235 236 237 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 231 def track_page_view(path) res = "" unless @noop == true res = track_it(path) end res end |
#urchin_url(ssl = false) ⇒ Object
102 103 104 105 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 102 def urchin_url(ssl = false) protocol = (ssl == true) ? 'https' : 'http' "#{protocol}://#{GA_DOMAIN}/#{GA_IMAGE}" end |
#utm_campaign ⇒ Object
209 210 211 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 209 def utm_campaign self.campaign end |
#utm_content ⇒ Object
226 227 228 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 226 def utm_content self.content end |
#utm_medium ⇒ Object
218 219 220 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 218 def utm_medium self.medium end |
#utm_source ⇒ Object
213 214 215 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 213 def utm_source self.source end |
#utm_term ⇒ Object
222 223 224 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 222 def utm_term self.term end |
#utmac ⇒ Object
utmac Account String. Appears on all requests. utmac=UA-2202604-2
108 109 110 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 108 def utmac self.analytics_id end |
#utmcc ⇒ Object
utmcc
Cookie values. This request parameter sends all the cookies requested from the page.
utmcc=__utma%3D117243.1695285.22%3B%2B __utmz%3D117945243.1202416366.21.10. utmcsr%3Db%7C utmccn%3D(referral)%7C utmcmd%3Dreferral%7C utmcct%3D%252Fissue%3B%2B
201 202 203 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 201 def utmcc self. end |
#utmcn ⇒ Object
utmcn Starts a new campaign session. Either utmcn or utmcr is present on any given request. Changes the campaign tracking data; but does not start a new session
utmcn=1
187 188 189 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 187 def utmcn self.new_campaign_session end |
#utmcr ⇒ Object
utmcr
Indicates a repeat campaign visit. This is set when any subsequent clicks occur on the same link. Either utmcn or utmcr is present on any given request.
utmcr=1
194 195 196 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 194 def utmcr self.repeat_campaign_visit end |
#utmcs ⇒ Object
utmcs
Language encoding for the browser. Some browsers don't set this, in which case it is set to "-"
utmcs=ISO-8859-1
121 122 123 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 121 def utmcs self.language_encoding end |
#utmdt ⇒ Object
205 206 207 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 205 def utmdt self.page_title end |
#utmhn ⇒ Object
utmhn
Host Name, which is a URL-encoded string. utmhn=x343.gmodules.com
114 115 116 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 114 def utmhn self.domain end |
#utmip ⇒ Object
utmip Remote IP address
175 176 177 178 179 180 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 175 def utmip return '' if self.remote_address.blank? # 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 self.remote_address.to_s.gsub(/([^.]+\.[^.]+\.[^.]+\.)[^.]+/,"\\1") + "0" end |
#utmje ⇒ Object
utmje
Indicates if browser is Java-enabled. 1 is true. utmje=1
127 128 129 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 127 def utmje self.java_enabled end |
#utmn ⇒ Object
utmn
Unique ID generated for each GIF request to prevent caching of the GIF image. utmn=1142651215
133 134 135 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 133 def utmn ActiveSupport::SecureRandom.random_number(9999999999).to_s end |
#utmr ⇒ Object
utmr
Referral, complete URL. utmr=http://www.example.com/aboutUs/index.php?var=selected
169 170 171 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 169 def utmr self.referrer end |
#utmsc ⇒ Object
utmsc
Screen color depth utmsc=24-bit
139 140 141 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 139 def utmsc self.screen_color_depth end |
#utmsr ⇒ Object
utmsr
Screen resolution utmsr=2400x1920&
145 146 147 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 145 def utmsr self.screen_resolution end |
#utmul ⇒ Object
utmul
Browser language. utmul=pt-br
151 152 153 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 151 def utmul self.browser_language end |
#utmwv ⇒ Object
utmwv
Tracking code version utmwv=1
157 158 159 |
# File 'lib/analytics_goo/google_analytics_adapter.rb', line 157 def utmwv self.tracking_code_version end |