Search code examples
phphtmlgoogle-analyticsjquery-cycle2

Why is Google Analytics not recording clicks when used in Cycle 2?


I am using Cycle 2 for a news ticker having 3 server side generated articles. I am attempting to use the onClick syntax for the ga.js version of analytics. As far as I can tell, I've done it correctly, but I have been consistently getting zero clicks for two weeks, which makes me think there may be a problem (I should mention that I've clicked on it to test it with no results, as it has occurred to me that it's possible that no one clicked it). Here's what I have:

<div class="cycle-slideshow"
     data-cycle-pause-on-hover="true"
     data-cycle-fx="fade" 
     data-cycle-timeout="6000"
     data-cycle-slides="> div"
     >
    <div><a href="<? echo $url1; ?>" onclick="_gaq.push(['_trackEvent', 'ReadThisNow', 'Click', '<? echo $title1; ?>']);"><? echo $title1; ?></a></div>

    <div><a href="<? echo $url2; ?>" onclick="_gaq.push(['_trackEvent', 'ReadThisNow', 'Click', '<? echo $title2; ?>']);"><? echo $title2; ?></a></div>

    <div><a href="<? echo $url3; ?>" onclick="_gaq.push(['_trackEvent', 'ReadThisNow', 'Click', '<? echo $title3; ?>']);"><? echo $title3; ?></a></div>


</div>

I left the PHP echo statements in since although I don't think they are the cause, it's possible they are. There is no html being output, only URL's and titles.

I've been using analytics right along with other projects, so I suspect there is some problem with using it in Cycle 2, but I've found nothing documenting it. What is going wrong here?


Solution

  • Check the output and put special attention to single vs double quotes appearances