I run a website that has lots of affiliate links. These links are loaded via AJAX. I'd like to be able to track outbound clicks on these links.
The standard approach to using Google Analytics to track links is to use the pageTracker._trackPageview() function. I've tried this to no avail. Here's my code:
<a href=<?php echo $link_loc ?> target = "_blank" class="affiliateLink" onclick="pageTracker._trackPageview('/event/outgoing?');">Link Text</a>
As is suggested, I put my Google Analytics standard tracking code in between the opening body tag and the above code.
Does anyone see anything wrong with my code? Could the problem be the fact that the links are loaded via AJAX?