Onclick Event in Google Analytics

I'm trying to use Google Analytics event tracking feature and I'm having a tough time see if I've got it right. (Well I'm pretty sure it's not right so far).

I have three events that I am tracking two are standard clicks on a link and one is a button submission.

One is a print window that opens when I click on a button for Print.

I feel like I've gotten this pretty close... but I'm not seeing any events show up in my Google Analytics account...

Anybody see anything wrong with my code.. or format.

GA's explanation his here:


Standard Link Event

<a href="price_quote.php?action=noname" onClick="pageTracker._trackEvent('QUOTE', 'NN-Quote', 'Unregistered Price Quote','299.00');"><img alt="" src="images/price-quote-07.gif" height="33" border="0" /></a>

Print event (link)

<a href="#" onClick="window.print(); return false; pageTracker._trackEvent('QUOTE', 'NN-Print', 'Print Quote');">

Email event: (button)

<input name="" src="images/email_quote.jpg" alt="Email Quote" onclick="return validate(); pageTracker._trackEvent('QUOTE', 'Email', 'Email Quote');" type="image">

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Tony McCreathTechnical SEO ConsultantCommented:
Your first one should work. For the rest your problem is that you return before the event tracking code is hit. return effectively stops the execution flow so anything after it is not run.

If you return true then the url then the browser will change to the url in the href attribute. So if you don't want a url change, then return false.

And you should use javascript:void(0); instead of #. It's a better way to tell a browser to do nothing.

Try this...

Standard Link Event

<a href="price_quote.php?action=noname" onclick="pageTracker._trackEvent('QUOTE', 'NN-Quote', 'Unregistered Price Quote','299.00'); return true;"><img alt="what does this image contain?" src="images/price-quote-07.gif" height="33" width="??" border="0" /></a>

Print event (link)

<a href="javascript:void(0);" onclick="window.print(); pageTracker._trackEvent('QUOTE', 'NN-Print', 'Print Quote'); return false;">

Email event: (button)

<input name="????" src="images/email_quote.jpg" alt="Email Quote" onclick="if (validate()) {pageTracker._trackEvent('QUOTE', 'Email', 'Email Quote'); return true;} else {return false;}; " type="image">

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
cxs410Author Commented:
Great, complete answer.
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
Web Development

From novice to tech pro — start learning today.