Last active
December 26, 2015 23:19
-
-
Save rob-bar/7230047 to your computer and use it in GitHub Desktop.
base #coffeescript #jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
helper = | |
track_event: (category, label, value) -> | |
try | |
# console.log "track: category: #{category} - label: #{label} - value: #{value}" | |
if label? and value? | |
_gaq.push ['_trackEvent', category, label, value] | |
else if label? | |
_gaq.push ['_trackEvent', category, label] | |
else | |
_gaq.push ['_trackEvent', category] | |
catch err | |
# console.log "couldn't track event: category: #{category} - label: #{label} - value: #{value}" | |
track_page: (frag) -> | |
# console.log "track: page: frag: #{frag}" | |
_gaq = window._gaq || [] | |
_gaq.push(['_trackPageview', "/#{frag}"]) | |
site = | |
page: $('body').attr 'data-page' | |
index: () -> | |
if typeof site[site.page] is "function" | |
do site[site.page] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment