Skip to content

Instantly share code, notes, and snippets.

@namtrok
Created August 7, 2013 14:02
Show Gist options
  • Select an option

  • Save namtrok/6174298 to your computer and use it in GitHub Desktop.

Select an option

Save namtrok/6174298 to your computer and use it in GitHub Desktop.
jquery code to enable Google Analytics event tracking on all form fields
<script>
jQuery(document).ready(function() {
jQuery("input, textarea, select").on('focus', function() {
_gaq.push(['_trackEvent', jQuery(this).closest('form').attr('class'), jQuery(this).attr('name'), jQuery(this).val()]);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment