Skip to content

Instantly share code, notes, and snippets.

@kressaty
Created September 24, 2012 21:20
Show Gist options
  • Save kressaty/3778455 to your computer and use it in GitHub Desktop.
Save kressaty/3778455 to your computer and use it in GitHub Desktop.
Track Form Abandonment in Google Analytics
// NOTE: this assumes you have loaded jQuery
$(document).ready(function() {
// REPLACE 'UNIQUE_FORM_ID' BELOW WITH THE ID OF YOUR FORM
$('#UNIQUE_FORM_ID input').blur(function () {
if($(this).val().length > 0) {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_full', $(this).attr('name')]);
}
else {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_empty', $(this).attr('name')]);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment