Sha256: 620c0fbe4e8982216a00ed212125948aafb30f256b9ffcad969419df1a0dda5f

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

window.Track=
  defaults: {}
  elements:(els, event, category, name, options)->
    els.on "#{event}.track", (ev)=>
      el = @target ev
      options = $.extend({}, @defaults, options)
      options.action = ev.type
      @event category, name, options
    #els.addClass 'tracked'
  visit:(category, name, options)->
    options = $.extend({}, @defaults, options)
    options.action = 'visit'
    @event category, name, options
  event:(category, name, options)->
    options = $.extend({}, @defaults, options)
    funnel = true
    funnel = options.funnel if options.funnel?
    if options.action?
      name = "#{options.action}_#{name}"
    @gaq_funnel_event category, name if funnel
    @gaq_event category, name, options.properties
    @kmq_event category, name, options.properties
  target:(ev)->
    el = ev.target || ev.srcElement
    el = el.parentNode if el.nodeType == 3
    el
  gaq_funnel_event:(category, name)->
    _gaq ?= []
    url = "/_event/#{category}/#{name}"
    _gaq.push ['_trackPageview', url]
  gaq_event:(category, name, properties)->
    _gaq ?= []
    gaq_attrs = ['_trackEvent', category, name]
    gaq_attrs.push JSON.stringify(properties) if properties?
    _gaq.push gaq_attrs
  kmq_event:(category, name, properties)->
    _kmq ?= []
    kmq_attrs = ['record', "#{category} - #{name}"]
    kmq_attrs.push properties if properties?
    _kmq.push kmq_attrs


(($)->
  $.fn.track = (event, category, action, options)->
    Track.elements @, event, category, action, options
    @
) jQuery

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
laces-0.1.0 templates/app/assets/javascripts/lib/actinology.coffee