Search code examples
javascriptjqueryanalytics

Analytics JS onclick voided other classes?


I have a jQuery Parallax Vertical scrolling website, I'm attempting to track the clicks to the divs with analytics.

I've done a simple test, and the below seems to track correctly.

onclick="javascript: _gaq.push(['_trackPageview', 'PageArea']);">

But when I add it to my menus that have active rollovers and use the parallax transition. Where I place that snippet kills a feature. For instance, I put it at the end as I did with my previous test - and it kills the rollover but everything else is fine. I put it at the beggining it kills the parallax transition. Any suggestions?

Below is the area in Question:

<li><a href=#manned-flight a class="manned-flight" onMouseOver= "if (document.images) document.booksbtnblckheadr.src= 'img/Btns/RedBooksheadbtn.gif';" onMouseOut= "if (document.images) document.booksbtnblckheadr.src= 'img/Btns/booksbtnblckheadr.gif' onclick="javascript: _gaq.push(['_trackPageview', 'PageArea']);"><img src="img/Btns/booksbtnblckheadr.gif" name=booksbtnblckheadr border=0></a></li> 

Solution

  • I think it was as simple as a syntax error. Below seems to work fine, just gotta make sure it tracks successfully.

    <li><a href="#manned-flight" class="manned-flight" onMouseOver= "if (document.images) document.booksbtnblckheadr.src= 'img/Btns/RedBooksheadbtn.gif';" onMouseOut= "if (document.images) document.booksbtnblckheadr.src= 'img/Btns/booksbtnblckheadr.gif';" onclick="javascript: _gaq.push(['_trackPageview', 'PageArea']);"><img src="img/Btns/booksbtnblckheadr.gif" name="booksbtnblckheadr" border=0></a></li>