What is wrong with my analytics code?

1 replies
  • SEO
  • |
I am trying to do event tracking for a single image button and I can't seem to get any events to register a click in analytics.

Here is my main analytics code: (with some parts hidden)

-------------------------------------------------------------

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push( ['_setAccount', 'UA-xxxxxxx-x'],['_trackPageview'] );

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[... s.parentNode.insertBefore(ga, s);
})();

window.onload = function() {
if(_gaq.I==undefined){
_gaq.push(['_trackEvent', 'tracking_script', 'loaded', 'ga.js', ,true]);
ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
s = document.getElementsByTagName('script')[...
gaScript = s.parentNode.insertBefore(ga, s);
} else {
_gaq.push(['_trackEvent', 'tracking_script', 'loaded', 'dc.js', ,true]);
}
};
</script>

--------------------------------------------------------------------------


Here is my onclick event code that doesn't seem to be working. Can anyone verify that it is set up properly?

-------------------------------------------------------------------------
<a onClick="_gaq.push(['_trackEvent', 'AffiliateClick', 'AffiliateName', 'my-page-name']);" href="http://affiliate-link..." rel="nofollow"><img title="" class="alignnone size-full wp-image-24323" alt="get started now" src="http://... width="520" height="187" /></a>
#analytics #code #wrong

Trending Topics