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:

http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html

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

cxs410Asked:
Who is Participating?
 
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

0
 
cxs410Author Commented:
Great, complete answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.