Class: Analytical::Modules::Chartbeat
- Inherits:
-
Object
- Object
- Analytical::Modules::Chartbeat
- Includes:
- Base
- Defined in:
- lib/analytical/modules/chartbeat.rb
Instance Attribute Summary
Attributes included from Base
#command_store, #initialized, #options, #tracking_command_location
Instance Method Summary collapse
- #init_javascript(location) ⇒ Object
-
#initialize(options = {}) ⇒ Chartbeat
constructor
A new instance of Chartbeat.
Methods included from Base
#init_location, #init_location?, #process_queued_commands, #protocol, #queue
Constructor Details
#initialize(options = {}) ⇒ Chartbeat
Returns a new instance of Chartbeat.
6 7 8 9 |
# File 'lib/analytical/modules/chartbeat.rb', line 6 def initialize(={}) super @tracking_command_location = [:head_prepend, :body_append] end |
Instance Method Details
#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 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/analytical/modules/chartbeat.rb', line 11 def init_javascript(location) init_location(location) do case location.to_sym when :head_prepend js = <<-HTML <!-- Analytical Head Init: Chartbeat --> <script type="text/javascript">var _sf_startpt=(new Date()).getTime();</script> HTML js when :body_append js = <<-HTML <!-- Analytical Body Init: Chartbeat --> <script type="text/javascript"> var _sf_async_config={uid:#{[:key]}, domain:"#{[:domain]}"}; (function(){ function loadChartbeat() { window._sf_endpt=(new Date()).getTime(); var e = document.createElement('script'); e.setAttribute('language', 'javascript'); e.setAttribute('type', 'text/javascript'); e.setAttribute('src', (("https:" == document.location.protocol) ? "https://s3.amazonaws.com/" : "http://") + "static.chartbeat.com/js/chartbeat.js"); document.body.appendChild(e); } var oldonload = window.onload; window.onload = (typeof window.onload != 'function') ? loadChartbeat : function() { oldonload(); loadChartbeat(); }; })(); </script> HTML js end end end |