public
Created

Track Form Abandonment in Google Analytics

  • Download Gist
ga-form-abandonment.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13
// 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')]);
}
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.