MariMari Del Riccio
MariMari Del Riccio

Reputation: 1

Event tracking google analytics not working properly

I have added an event to track the number of downloads for my application. This is the code I have used:

<div class="downloadiphone" style="top: 319px; left: 463px;">
<a class="blocklink" title="Download for your iPhone" 
href="http://itunes.apple.com/se/app/mikz/id477146876?mt=8"  
onClick="_gaq.push(['_trackEvent', 'Iphone', 'Download', 'HomepageB2C']);” 
target="_blank">x</a>
</div>

When I check on Google analytics it says that 60 of my visits sent events. 0 total events Is there something wrong in the code? I have installed it some weeks ago, so it should definitely report the events properly.

Upvotes: 0

Views: 815

Answers (2)

rasicoc
rasicoc

Reputation: 310

It looks like you are using the asynchronous event code, but make sure you are also using the asynchronous tracking code as well. We had a similar situation where the new event code didn't work correctly until we updated to the newest tracking code too. Your tracking code should look something like this:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9705946-1']);
_gaq.push(['_trackPageview']);

(function() {var 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';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(ga, s);
})();

Upvotes: 0

Aaron Toledo
Aaron Toledo

Reputation: 11

The visitor's browser may be leaving your page before the tracking code receives a valid response back from Google's servers. Try introducing a slight delay prior to allowing the normal link behavior to take place. It was well documented in older versions of Google Analytics, but not as well in the Asynchronous documentation:

http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55527

Upvotes: 1

Related Questions