Sha256: 68f17bffe0cf380fff83c7579611595520486148713c1de30954dbe2cbaad7b8
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
module Analytical module Chartbeat class Api include Analytical::Base::Api def initialize(options={}) super @tracking_command_location = [:head_prepend, :body_append] end 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:#{options[:key]}, domain:"#{options[: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 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
analytical-1.8.0 | lib/analytical/chartbeat.rb |
analytical-1.7.0 | lib/analytical/chartbeat.rb |
analytical-1.6.0 | lib/analytical/chartbeat.rb |