Skip to content

Instantly share code, notes, and snippets.

@blafrance
Forked from kressaty/ga-form-abandonment.js
Created November 11, 2012 04:49
Show Gist options
  • Save blafrance/4053753 to your computer and use it in GitHub Desktop.
Save blafrance/4053753 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