Tracking Exit/Outbound Links through Google Analytics

Google Analytics Exit Link Screenshot
Google Analytics Exit Link Screenshot

Google Analytics is the enterprise-class web analytics solution that gives you rich insights into your website traffic and marketing effectiveness. Powerful, flexible and easy-to-use features now let you see and analyze your traffic data in an entirely new way. With Google Analytics, you’re more prepared to write better-targeted ads, strengthen your marketing initiatives and create higher converting websites.

I use Google Analytics for my own site and other sites I work on.  I mostly use this tool to track the visitor and my popular post, keywords and also the click on Site Overlay. I had never tracked exit/outbound link with Google Analytics. One day, my client asked to me research about it and track the exit link.  Then my search for the exit link tracker begins. I fund lot of codes but non of them work properly. Finally, I was lucky enough to get read an article written by Jordi Romkema. But now I see that his site is not available. So, I am writing here again with reference to his code. If you are finding difficult to track the exit/outbound link then just follow the instruction below:

1) Create a Javascript file. For example let’s save it as exittracker.js and write the following code and save it.
var ExitTracker = Class.create({
initialize: function()
this.domain = document.location.toString().toLowerCase().split("/")[2];
if (item.href && (item.href != (document.location + "#")))
$(item).observe("click", this.track.bindAsEventListener(this));
track: function(e)
var el = e.element();
var exit_domain = el.href.split("/")[2].toLowerCase();
if (this.domain.toLowerCase().indexOf(exit_domain) == -1)
if (typeof pageTracker != "undefined")
pageTracker._trackPageview("/exit/" + el.href);

2) Now insert the following code to link the scripts. You should place the code right after your Google Analytics code:
<!-- Google Analytics code here -->
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="exittracker.js"></script>
<script type="text/javascript">
new ExitTracker();

Note: Click here to download the prototype.js

If you find difficult to write the code then Click here to download the set of prototype.js and exittracker.js . Then you can just add the code to link these two file after your Google analytics code.

If there is any problem then just write a comment and then I will reply you back.

5 Replies to “Tracking Exit/Outbound Links through Google Analytics”

  1. Dear Sakin,

    I found your explanation valuable though not entirely clear considering the scripting for my webpage is not in my hands – though the analytics is. If possible, could you spare a few minutes for a skype conversation to clarify a few points about tracking exit links via GA? This would be most helpful in understanding. We could even include a link ono our site to your blog in exchange for your time.

    With warm regards,

    [email protected]

  2. On my blog I added event tracking on onclick for the exit links and as the category I set them all to be Exit, then as action the href element for the outbound link and as the label I set the page url where the user is now, so now I can track exactly how many guys leave my site, to which sites they click and from what pages of mine. Of course, the post pages have the highest exit rate.