Tuesday, December 4, 2012

How to track form anxiety in GA

Forms seem simple.  Either someone fills them out or they don't.  But that's not always the whole story.  

Form anxiety is when someone who would otherwise fill out your form chooses not to or stops half way through, because they don't feel comfortable.  There is also form frustration which can occur when someone makes a mistake or doesn't know the answer and decides to give up.  If you're only keeping track of the number of people who successfully complete your form, you could be leaving your visitors hanging.

I always recommend tracking these behaviors because they are generally easy to fix and result in big wins.  So, how do you do it?  ...with Google Analytics and events.

First, make sure that you are tracking your form as a goal or e-commerce transaction.  This will help you keep track of the raw number of completions.  

Next, you should be tracking form field input success and errors.  The goal is to see if you have one form field that is prone to errors or if your visitors consistently get to a particular section of your form and stop.  

I suggest tracking on blur.  Blur is when the user clicks on another input or part of the page.  It is possible to lose a couple of events with blur, but it is the least obtrusive to the process and will show you how many times someone visits a form field.  If you already have validation that verifies the user's input after each step, you can just add the tracking there.

Now for some sample code.  The GA event is highlighted in green.  This code is not meant to be plug-n-play, it is just to illustrate the point.
    $('input').bind('blur',validate_and_log); 
    function validate_and_log()
    {
        var formId= 'My Form 1';
        var validity = 'invalid';
        var eleName = $(this).attr('name'); 
        //do the necessary validation
        if($(this).val() != '')
        {
                validity = 'valid';
        } 
        _gaq.push(['_trackEvent', 'Forms', formId, eleName, validity]);
    }