Sha256: 4bb2157f57cd27da15e0a4653585fbd7be0411baf025b5c19cedd99f9bf6fbb4
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
class Rack::Tracker::Zanox < Rack::Tracker::Handler # name of the handler # everything after is passed as options class Mastertag < OpenStruct def write to_h.except(:id).map do |k,v| "var zx_#{k} = #{v.to_json};" end.join("\n") end end class Lead < OpenStruct # Example: OrderID=[[DEFC-4321]]&CurrencySymbol=[[EUR]]&TotalPrice=[[23.40]] def write to_h.map do |k,v| "#{k.to_s.camelize}=[[#{v}]]" end.join('&') end end class Sale < OpenStruct def write to_h.map do |k,v| "#{k.to_s.camelize}=[[#{v}]]" end.join('&') end end self.position = :body def mastertag # First event should be stronger, e.g. one signs up and gets redirected to homepage # "sign up" should be tracked instead of "view homepage" events.select{ |event| event.class.to_s.demodulize == 'Mastertag' }.first end def lead_events events.select{ |event| event.class.to_s.demodulize == 'Lead' } end def sale_events events.select{ |event| event.class.to_s.demodulize == 'Sale' } end def render Tilt.new( File.join( File.dirname(__FILE__), 'template', 'zanox.erb') ).render(self) end # this is called with additional arguments to t.zanox def self.track(name, *event) { name.to_s => [event.last.merge('class_name' => event.first.to_s.capitalize)] } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-tracker-1.0.1 | lib/rack/tracker/zanox/zanox.rb |