Skip to content

Instantly share code, notes, and snippets.

@namtrok
namtrok / Place in html <head>
Created August 7, 2013 14:02
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>