Back in August 2008, I wrote a post on how to optimize form length with input analysis with Google Analytics. This is still a very relevant topic, as forms are still essential to collecting data from visitors.  I still cringe when I see a form that has a ton of fields, and I know many of you do as well.  This post will show you how to take action to shorten your forms and remove unneeded fields, which usually results in higher conversion rates for your forms.

The old post referenced the traditional/syncronous version of the Google Analytics tracking code. This new post features the newest release by Google, which is the asynchronous code execution.

Please note that I am not going to re-do the entire post, just the code portion.

So here is the code update:

Traditional Snippet (Synchronous):

function validate()
{
isEntered(document.getElementById('name'),'name');
isEntered(document.getElementById('email'),'email');
isEntered(document.getElementById('phone'),'phone');
isEntered(document.getElementById('company'),'company');
isEntered(document.getElementById('comments'),'comments');

frm.action='/thankyou.aspx?src=contact_us.htm';
} 

function isEntered(el, field_name)
{
     if((el.value=="") || (el.value==null))
     {
     pageTracker._trackPageview('/contact_us.htm/empty/'+field_name);
     }

     else
     {
     return false;
     }
}

Asynchronous Snippet (NEW):

function validate()
{
isEntered(document.getElementById('name'),'name');
isEntered(document.getElementById('email'),'email');
isEntered(document.getElementById('phone'),'phone');
isEntered(document.getElementById('company'),'company');
isEntered(document.getElementById('comments'),'comments');

frm.action='/thankyou.aspx?src=contact_us.htm';
} 

function isEntered(el, field_name)
{
     if((el.value=="") || (el.value==null))
     {
	 _gaq.push(['_trackPageview', '/contact_us.htm/empty/'+field_name]);
     }

     else
     {
     return false;
     }
}

 

Related Posts:

Message Sent

Thank you for registering.

Cardinal Path hosted a live session to connect with you and answer all your questions on Google Analytics.
Get all the expertise and none of the consultancy fees in this not-to-be-missed, rapid-fire virtual event.

Thank you for submitting the form.

Thank you for submitting the form.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you.

Click here to download access the tool.

Message Sent

Thank you for registering.

Message Sent

Thank you.

Message Sent

Thank you.

Message Sent

Thank you

Message Sent

Thank you

Message Sent

Thank you.

Message Sent

Thank you

Message Sent

Thank you.

Message Sent

Success!
Your message was received.

Thank you.

Thank you for registering.

Cardinal Path is continuing with its series of free training. Next we are conducting training on Google Data Studio. Check it out here.

Message Sent

Thank you for registering.

Thank you for your submission.

Your request has been submitted and a rep will reach out to you shortly.

Message Sent

Thank you for your interest.

Thank you for registering.

You should receive a confirmation email from GoToWebinar with your unique webinar login information. If you do not receive this email or have trouble logging in to the event, please email asmaa.mourad@cardinalpath.com.

Thank you for subscribing!

You're now looped into the world's largest GMP resource hub!

Thank you for your submission.

Thank you for your submission.

Thank you for your submission.

Thank you for your submission.

Message Sent

Thank you for registering.

Message Sent

Thank you for your submission.

Thank you for your submission.

Message Sent

Thank you for registering.

Thank you for registering.​

Paid media spend by Government websites increased a whopping 139% YoY in 2020.

2020 Online Behavior Live Dashboard

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

2020 Online Behavior Live Dashboard

Thank you for your submission.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Thank you for registering.

Message Sent

Success! Thank you
for reaching out.