Created
November 18, 2014 05:36
-
-
Save patrickfox/6e3ac86b04c34a5a228f to your computer and use it in GitHub Desktop.
a7s.js - an analytics framework
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
(function () { | |
var init, onclick_tracked_item, selector, track_event, track_page, tracked_actions; | |
selector = '[data-a7s]'; | |
init = function() { | |
return $(selector).on('click', onclick_tracked_item); | |
}; | |
onclick_tracked_item = function(e) { | |
var id, target; | |
target = $(e.target); | |
id = target.data('a7s'); | |
if (tracked_actions[id]) { | |
return tracked_actions[id].call(); | |
} | |
}; | |
track_page = function(value) { | |
//_gaq.push(['_trackPageview', value]) | |
return console.log('Page load: ' + value); | |
}; | |
track_event = function(category, action, value) { | |
//_gaq.push(['_trackEvent', cat, action, value]) | |
return console.log('Click tracked:' + category + action + value); | |
}; | |
/* | |
Put all custom click and page load actions in tracked_actions | |
*/ | |
tracked_actions = { | |
'adduser_pageload': function() { | |
return track_page('AddUser PageLoad'); | |
}, | |
'adduser_save': function() { | |
return track_event('AddUser', 'Click', 'Save'); | |
}, | |
'adduser_cancel': function() { | |
return track_event('AddUser', 'Click', 'Cancel'); | |
} | |
}; | |
$.a7s = init; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment