Class: Analytical::Modules::Totango
- Inherits:
-
Object
- Object
- Analytical::Modules::Totango
- Includes:
- Base
- Defined in:
- lib/analytical/modules/totango.rb
Instance Attribute Summary
Attributes included from Base
#command_store, #initialized, #options, #tracking_command_location
Instance Method Summary collapse
- #event(name, *args) ⇒ Object
- #identify(id, *args) ⇒ Object
- #init_javascript(location) ⇒ Object
-
#initialize(options = {}) ⇒ Totango
constructor
A new instance of Totango.
Methods included from Base
#init_location, #init_location?, #process_queued_commands, #protocol, #queue
Constructor Details
#initialize(options = {}) ⇒ Totango
Returns a new instance of Totango.
6 7 8 9 |
# File 'lib/analytical/modules/totango.rb', line 6 def initialize(={}) super @tracking_command_location = :body_prepend end |
Instance Method Details
#event(name, *args) ⇒ Object
42 43 44 45 |
# File 'lib/analytical/modules/totango.rb', line 42 def event(name, *args) data = args.first || {} "tracker.track(\"#{name}\", \"#{data[:module]}\");" end |
#identify(id, *args) ⇒ Object
37 38 39 40 |
# File 'lib/analytical/modules/totango.rb', line 37 def identify(id, *args) data = args.first || {} "tracker.identify(\"#{data[:organization]}\",\"#{data[:email]}\");" end |
#init_javascript(location) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/analytical/modules/totango.rb', line 11 def init_javascript(location) init_location(location) do js = " <!-- Analytical Init: Totango -->\n <!-- step 1: include the loader script -->\n <script src='//s3.amazonaws.com/totango-cdn/sdr.js'></script>\n\n <!-- step 2: initialize tracking -->\n <script type=\"text/javascript\">\n try {\n var tracker = new __sdr(\\\"\#{options[:key]}\\\");\n } catch (err) {\n // uncomment the alert below for debugging only\n // alert (\"Totango tracking code load failure, tracking will be ignored\");\n quite = function () {};\n var tracker = {\n track: quite,\n identify: quite\n };\n }\n </script>\n HTML\n js\n end\nend\n" |