Module: AnalyticsGoo

Defined in:
lib/analytics_goo/google_analytics_adapter.rb,
lib/analytics_goo.rb

Overview

utmcs

Language encoding for the browser. Some browsers dont set this, in which case it is set to "-"
utmcs=ISO-8859-1

utmje

Indicates if browser is Java-enabled. 1 is true. 	utmje=1

utmsc

Screen color depth 	utmsc=24-bit

utmsr

Screen resolution 	utmsr=2400x1920&

utmul

Browser language. 	utmul=pt-br

utmwv

Tracking code version 	utmwv=1

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

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

utmcc

Cookie values. This request parameter sends all the cookies requested from the page.

Defined Under Namespace

Modules: InstanceMethods Classes: AnalyticsAdapter, AnalyticsAdapterNotFound, GoogleAnalyticsAdapter

Class Method Summary collapse

Class Method Details

.config(type, analytics = {}) ⇒ Object

Factory for returning the appropriate analytics object. The type is a symbol that defines the type of analytics tracker you want to create. Currently, the only acceptable value is :google_analytics. The analytics hash holds the required keys of analytics_id and the domain of the adapter that you are configuring. Setting the key rails_core_mixins to true will mixin an accessor for this object into the core rails framework classes (active_record, action_controller and action_mailer). The default for this is false so that there are no rails dependencies on the gem. The key environment by default is set to “production”. The rails mixin functionality checks this value against its RAILS_ENV then it calls out to the analytics only if the value is nil or matches.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/analytics_goo.rb', line 35

def self.config(type, analytics = {})
  begin
    s = type.to_s + "_adapter"
    adapter = "AnalyticsGoo::" + s.camelize
    analytics[:environment] = "production" if analytics[:environment].nil?
    if analytics[:rails_core_mixins] == true
      analytics[:noop] = (RAILS_ENV != analytics[:environment])
      tracker = adapter.constantize.new(analytics)
      for framework in ([ :active_record, :action_controller, :action_mailer ])
        framework.to_s.camelize.constantize.const_get("Base").send :include, AnalyticsGoo::InstanceMethods
      end
      silence_warnings { Object.const_set "ANALYTICS_TRACKER", AnalyticsGoo::AnalyticsAdapter.new(tracker) }
    else
      tracker = adapter.constantize.new(analytics)
    end
    AnalyticsGoo::AnalyticsAdapter.new(tracker)
  rescue StandardError
    raise AnalyticsAdapterNotFound
  end
end