Tracking form intereactions with Google Analytics, Gravity forms and jQuery

We have a WordPress installation and we’re trying to track in Google analytics whenever a form field is clicked in Gravity Forms.

To do this we’ve got to push Analytics variables whenever the field is focussed. Here is the code we are using:-

Read More
<script type="text/javascript">
jQuery('#input_1_3').focus(function() {
    _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Name']);
});
jQuery('#input_1_4').focus(function() {
    _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Company Name']);
});
jQuery('#input_1_5').focus(function() {
    _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Email']);
});
jQuery('#input_1_11').focus(function() {
    _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Telephone']);
});
jQuery('#input_1_6').focus(function() {
    _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Questions/Comments']);
});

The input ID’s match up fine with the relevant ID’s on elements in the form, but it isn’t resulting in tracking in Analytics. There doesn’t appear to be any conflict with jQuery in WordPress, and no errors are resulting in Firebug.

Do you have any ideas as to why nothing is tracking?

Related posts

Leave a Reply

1 comment

  1. First you can check if this events really fired:

    jQuery('#input_1_3').focus(function() {
         alert("I'm focused");
        _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Name']);
    });
    

    If they not, use on() method to bind focus event:

    jQuery('#input_1_3').on('focus', function() {
             alert("I'm focused");
            _gaq.push(['_trackEvent', 'Form Tracking', 'Sidebar Quick Contact Form: Homepage', 'Name']);
        });