There is a tutorial on Google which explains How do I manually track clicks on outbound links?
However that tutorial doesn’t help a lot for non-geeks.
This is my effort to simply the outbound link tracking.
Assuming that you are using Asynchronous Google Analytics Tracking Code follow these steps
Add following code just before closing head </head>
<script type="text/javascript"> function recordOutboundLink(link, category, action) { _gat._getTrackerByName()._trackEvent(category, action); setTimeout('document.location = "' + link.href + '"', 100); } </script>
For each external/outbound link which you want to track add the tracking information
<a onclick="recordOutboundLink(this, 'External Website', 'externalwebsite.com');return false;" href="http://www.externalwebsite.com">
You can find this outbound link tracking report under Google Analytics Content->Even Tracking
You can see more details on this report from the menus in left.
Do you know how to do this without having to add tracking code to every single link? Is there a way to track all outgoing links easily?
Unfortunately yes, you have to add tracking code to each outgoing link.
I don’t think there is any other easier way to track all outgoing links.
At last! Someone has put it simply. Thank you!
hai
But that will not open a new page… What must be changed?
I think it is not possible to use _blank in the outbound link, so unfortunately you can’t open the link in a new window.
Ajay: did you ever get your _blank to work with event tracking?
Cheers,
Christopher
Nop.
AFAIK it is official that it doesn’t work. It is not possible.
You can retro-fit this to existing links in pages with Javascript. The example below uses jQuery. You’d need to add a script reference to jQuery (1.7 or above) and to the js file that includes the following code…
$(“a”).each(function() {
$(this).on(“click”, function() {
recordOutboundLink(this, $(this).attr(“alt”), $(this).attr(“src”));
});
});
Make sure you correctly set alt tags for each link.