Skip to content

Instantly share code, notes, and snippets.

@chrisbuttery
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbuttery/9948914 to your computer and use it in GitHub Desktop.
Save chrisbuttery/9948914 to your computer and use it in GitHub Desktop.
_trackEvent
module.exports = function(name){
document.addEventListener('blur', function(el){
if (!el.target.value){
_gaq.push(['_trackEvent', name, 'skipped', el.target.name]);
}
else {
_gaq.push(['_trackEvent', name, 'completed', el.target.name]);
}
}, true);
};
(function($) {
$(document).ready(function() {
$(':input').blur(function () {
if($(this).val().length > 0) {
_gaq.push(['_trackEvent', 'INSERT FORM NAME HERE', 'completed', $(this).attr('name')]);
}
else {
_gaq.push(['_trackEvent', 'INSERT FORM NAME HERE', 'skipped', $(this).attr('name')]);
}
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment