Sha256: 6392cb91777b4715d2f5231a5bc3f1441480da352700a68e2c8d07324aa44e46
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
module Analytical module KissMetrics class Api include Analytical::Base::Api def initialize(parent, options={}) super @tracking_command_location = :body_prepend end def init_javascript(location) init_location(location) do js = <<-HTML <!-- Analytical Init: KissMetrics --> <script type="text/javascript"> var _kmq = _kmq || []; function _kms(u){ setTimeout(function(){ var s = document.createElement('script'); var f = document.getElementsByTagName('script')[0]; s.type = 'text/javascript'; s.async = true; s.src = u; f.parentNode.insertBefore(s, f); }, 1); } _kms('//i.kissmetrics.com/i.js');_kms('#{options[:js_url_key]}'); </script> <script type="text/javascript"> _kmq.push(['pageView']); </script> HTML js end end def identify(id, *args) data = args.first || {} "_kmq.push([\"identify\", \"#{data[:email]}\"]);" end def event(name, *args) data = args.first || {} "_kmq.push([\"record\", \"#{name}\", #{data.to_json}]);" end def set(data) return '' if data.blank? "_kmq.push([\"set\", #{data.to_json}]);" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
analytical-1.5.0 | lib/analytical/kiss_metrics.rb |
analytical-1.4.0 | lib/analytical/kiss_metrics.rb |
analytical-1.3.0 | lib/analytical/kiss_metrics.rb |