Javascript Google Analytics Form Tracking

In my Google Analytics account I'm trying to track a form progression.  
I have the following code:
<input type="text" name="item_options[last_name]" value="" placeholder="Primary Operator Last Name" onBlur="if(document.testform.item_options[last_name].value != '');_gaq.push(['_trackPageview','/form/item_options[last_name]'])"/>

Open in new window

In this line::  
onBlur="if(document.testform.item_options[last_name].value != '');_gaq.push(['_trackPageview','/form/item_options[last_name]'])"
Chrome gives me an error:: Uncaught TypeError: Cannot read property 'item_options' of undefined
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

document.testform['item_options[last_name]'].value != ''

onBlur="if(document.testform['item_options[last_name]'].value != '');_gaq.push(['_trackPageview','/form/item_options[last_name]'])"

Open in new window

rgranlundAuthor Commented:
When I make that change, the error message changes;
Updated Form Field:
<input type="text" name="item_options[insured_last_name]" value="" Placeholder="Last Name" onBlur="if(document.mail_info['item_options[insured_last_name]'].value != '');_gaq.push(['_trackPageview','/form/item_options[insured_last_name]'])"/>	

Open in new window

ERROR Message:  Uncaught ReferenceError: _gaq is not defined

Do I need a dot before items options?
That just means that _gaq does not exist anywhere.  The likely cause is that the google analytics file is not loaded.  Here's the code you should be using:
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
The code that I get from Google is a little different.  Also, I realized that the error only occurs when I change a value in the form field that includes the tracking code.  The error either:

Uncaught TypeError: ga.push is not a function
Uncaught ReferenceError: product_liability is not defined

Here is all of the code:
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-XXXXX-X1', 'auto');
  ga('send', 'pageview');

<select name="item_options[product_liability]" onBlur="if(document.mail_info.item_options[product_liability].value != '');ga.push(['_trackPageview','/form/item_options[product_liability]'])">
							<option {selected} value="">None</option>
							<option {selected} value="{option_value}" data-liability_name="{option_name}">{option_name}</option>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.