Module: Analytical::Modules::Base
- Included in:
- Adroll, Adwords, Chartbeat, ClickTale, Clicky, Comscore, Console, CrazyEgg, DummyModule, Google, GoogleOptimizer, Hubspot, KissMetrics, Loopfuse, MicrosoftAds, Mixpanel, Optimizely, Performancing, Quantcast, Reinvigorate, Totango
- Defined in:
- lib/analytical/modules/base.rb
Instance Attribute Summary collapse
-
#command_store ⇒ Object
readonly
Returns the value of attribute command_store.
-
#initialized ⇒ Object
readonly
Returns the value of attribute initialized.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#tracking_command_location ⇒ Object
readonly
Returns the value of attribute tracking_command_location.
Instance Method Summary collapse
- #init_location(location, &block) ⇒ Object
- #init_location?(location) ⇒ Boolean
- #initialize(_options = {}) ⇒ Object
- #process_queued_commands ⇒ Object
- #protocol ⇒ Object
-
#queue(*args) ⇒ Object
This method generates the initialization javascript that an analytics service uses to track your site def init_javascript(location).
Instance Attribute Details
#command_store ⇒ Object (readonly)
Returns the value of attribute command_store.
5 6 7 |
# File 'lib/analytical/modules/base.rb', line 5 def command_store @command_store end |
#initialized ⇒ Object (readonly)
Returns the value of attribute initialized.
4 5 6 |
# File 'lib/analytical/modules/base.rb', line 4 def initialized @initialized end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/analytical/modules/base.rb', line 4 def @options end |
#tracking_command_location ⇒ Object (readonly)
Returns the value of attribute tracking_command_location.
4 5 6 |
# File 'lib/analytical/modules/base.rb', line 4 def tracking_command_location @tracking_command_location end |
Instance Method Details
#init_location(location, &block) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/analytical/modules/base.rb', line 68 def init_location(location, &block) if init_location?(location) @initialized = true if block_given? yield else '' end else '' end end |
#init_location?(location) ⇒ Boolean
60 61 62 63 64 65 66 |
# File 'lib/analytical/modules/base.rb', line 60 def init_location?(location) if @tracking_command_location.is_a?(Array) @tracking_command_location.map { |item|item.to_sym }.include?(location.to_sym) else @tracking_command_location.to_sym == location.to_sym end end |
#initialize(_options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/analytical/modules/base.rb', line 7 def initialize(={}) @options = @tracking_command_location = :body_prepend @initialized = false @command_store = @options[:session_store] || Analytical::CommandStore.new end |
#process_queued_commands ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/analytical/modules/base.rb', line 52 def process_queued_commands command_strings = @command_store.collect do |c| send(*c) if respond_to?(c.first) end.compact @command_store.flush command_strings end |
#protocol ⇒ Object
14 15 16 |
# File 'lib/analytical/modules/base.rb', line 14 def protocol @options[:ssl] ? 'https' : 'http' end |
#queue(*args) ⇒ Object
This method generates the initialization javascript that an analytics service uses to track your site def init_javascript(location)
44 45 46 47 48 49 50 51 |
# File 'lib/analytical/modules/base.rb', line 44 def queue(*args) return if @options[:ignore_duplicates] && @command_store.include?(args) if args.first==:identify @command_store.unshift args else @command_store << args end end |