Skip to content

Instantly share code, notes, and snippets.

@itsthatguy
Last active December 20, 2015 14:59
Show Gist options
  • Save itsthatguy/6150801 to your computer and use it in GitHub Desktop.
Save itsthatguy/6150801 to your computer and use it in GitHub Desktop.
%a.button(href="http://www.amazon.com/Son-of-Sedonia-ebook/dp/B00AO5ID9Q" data-type='mixpanel' data-name="Overview: Buy on Amazon")
Buy on Amazon
class MixpanelEvents
constructor: ->
@createEvents()
createEvents: ->
_self = @
$('body').find("[data-type='mixpanel']").click (e) ->
e.preventDefault()
mixpanel.track "Click: #{$(this).data('name')}", {}, -> _self.setURL($(e.target))
setURL: ($el) -> location.href = $el.attr('href') unless $el.data('redirect') == "false"
window.mixpanelEvents = new MixpanelEvents()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment