You can use Google Analytics to track clicks on links that lead away from your site. Because links that lead away from your site are not automatically tracked, you will need to manually tag all outbound links you want to track. To do this, you’ll add some JavaScript customizations to your page and to the links you want to track.
- Set up Event Tracking in your Analytics Tracking code. This is a simple matter of adding the following line to the tracking code for your pages after the page tracking object is set up:
1234<script>var pageTracker = _gat._getTracker('UA-XXXXX-X');pageTracker._trackPageview();</script>
- Add a JavaScript method in the head of your document to delay the outbound click by a fraction of a second. This delay will hardly be noticeable by the user, but it will provide the browser more time load the tracking code. Without this method, it’s possible that a user can click on the outbound link before the tracking code loads, in which case the event will not be recorded. Here’s what the JavaScript code in the section should look like (assuming you will use your own tracking code ID):
12345678910<script>function recordOutboundLink (link, category, action) {try {var pageTracker =_gat._getTracker("UA-XXXXX-X");pageTracker._trackEvent(category, action);setTimeout('document.location = "' + link.href + '"', 100)}catch (err) {}}</script>
- Update your outbound links to call the new function without first following the link. For example, to log every click on a particular link to www.example.com, you would use the _trackEvent() method in the link’s tag:
1<a href="http://www.example.com" onclick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">Trackable Link</a>
The example above uses the category label Outbound Links. This is a useful way to categorize all outbound links in the Event Tracking reports. It sets the specific name of the website as the second parameter in the call. With this structure in place, you could then see Outbound Links as one of the event categories and drill down to see which particular outbound links are the most popular. Be sure to use return false for the onClick handler, because without that statement the browser will follow the link before the recordOutboundLink method has a chance to execute.
For more information on using event tracking, see the Event Tracking Guide on Google Code.
Article Reference URL:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55527&cbid=-wlhzojb6oodb&src=cb&lev=index
Thanks for writing this up!
I need to use tracking on outbound links. However, I don’t know JavaScript that well. Is there any possible way you can re-post this article explaining in step by step detail on what code I should use and where I should add it to my pages?
For example on your steps:
1) I don’t know where to put this code.
2) I understand to put this in the head area of the web page but I don’t know what “assuming you will use your own tracking code ID” means
3) I don’t understand how to set this up. I don’t know what “Be sure to return false for the onClick handler” means.
My goal is to track a customer’s link or links and be able to have the customer go into Google Analytics and and see a detailed report by month of how many people are clicking on their links, on my site.
Any suggestions? Or are there any help forums you know of or people who are good offering detailed instructions to make this work?
Sincerely,
Mike
Also, I noticed that this blog entry is copied word for word here: http://www.anythingown.com/blog/index.php/2010/05/24/manually-track-clicks-on-outbound-links-by-using-google-analytics/comment-page-1/#comment-1799.
(I’m not sure why it’s copied on the other site).
Very nice. Congrats for the example and thank you for sharing with us this information.
Best regards,
Davis Ford
The example above uses the category label Outbound Links. This is a useful way to categorize all outbound links in the Event Tracking reports. It sets the specific name of the website as the second parameter in the call. With this structure in place, you could then see Outbound Links as one of the event categories and drill down to see which particular outbound links are the most popular. FoxMetrics.com is an actual-time platform that allows you to measure and track how people interact along with your internet, computer and cell packages including social media tracking. Fox Metrics is relied on through thousands of businesses similar to yours. Gain deeper insights into your shoppers, Web Analytics and building up your conversion.
thanks for your good post.
A couple of years ago, after making many inquires on many blogs (and even on a Google blog) and I even was in contact with a “Google Analytics” expert, no one has ever been able to give me a good answer to my original question. How do I track outbound click-throughs on my website? So, I am very impressed that someone (even several years later) was able to provide Foxmetrics.com.
However, I did find another company which provides tracking for click-throughs on outbound links, it’s called Analytics Engine. Their code works in-conjunction with Google Analytics and the outbound tracking reports are reported through Google Analytics Dashboard.
It’s a little tricky to figure out where to find the outbound statistics in the Google Analytics Dashboard but if anyone needs to know, please leave a message on this board and I’ll leave detailed instructions.