Class: Analytical::Modules::Reinvigorate

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/analytical/modules/reinvigorate.rb

Instance Attribute Summary

Attributes included from Base

#command_store, #initialized, #options, #tracking_command_location

Instance Method Summary collapse

Methods included from Base

#init_location, #init_location?, #process_queued_commands, #protocol, #queue

Constructor Details

#initialize(options = {}) ⇒ Reinvigorate

Returns a new instance of Reinvigorate.



6
7
8
9
# File 'lib/analytical/modules/reinvigorate.rb', line 6

def initialize(options={})
  super
  @tracking_command_location = :body_append
end

Instance Method Details

#context(data) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/analytical/modules/reinvigorate.rb', line 29

def context(data)
  return '' if data.blank?
  if data[:email]
    "var re_context_tag = \"mailto:#{data[:email]}\";"
  elsif data[:url]
    "var re_context_tag = \"http://#{data[:url]}\";"
  else
    "var re_context_tag = \"#{data.first.last}\";"
  end
end

#identify(id, *args) ⇒ Object



24
25
26
27
# File 'lib/analytical/modules/reinvigorate.rb', line 24

def identify(id, *args)
  data = args.first || {}
  "var re_name_tag = \"#{id}\";"
end

#init_javascript(location) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/analytical/modules/reinvigorate.rb', line 11

def init_javascript(location)
  init_location(location) do
    js = <<-HTML
    <!-- Analytical Init: Reinvigorate -->
    <script type="text/javascript">
      document.write(unescape("%3Cscript src='" + (("https:" == document.location.protocol) ? "https://ssl-" : "http://")
      + "include.reinvigorate.net/re_.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    HTML
    js
  end
end

#track(data, *args) ⇒ Object



40
41
42
43
44
# File 'lib/analytical/modules/reinvigorate.rb', line 40

def track(data, *args)
  "try {
    reinvigorate.track(\"#{options[:key]}\");
  } catch(err) {}"
end