Track Outbound Links and Downloads with Google Analytics

Google Analytics Logo Statcounter announced a couple of weeks ago an update on their newest version of their tracking software. The SC4 update added two major changes. The first allowing for exit link tracking, or in other words, track the destinations of visitors leaving your site. The other was the ability to compile, download stats, as in track stats for pdf and other files available on your site. This got us wondering, what igf you were in a situation where Statcounter was not an option, and why Google Analytics did not offer something similar out of the box. In our search for answers and we found  an essential add-on for any Google Analytics implementation. Immeria started the ball rolling, with a script to to track outbound links and downloads which has now morphed into a wonderful open source project. In short, gaAddons Google Analytics implementation. Best of all, its easy to implement. The first step is download the code (we have linked to the SVN, the most up to date code). Place it in a folder and call it after the main Google Analytics script. Below is an example code, you will need to add your Google Analytics Site ID.

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E"));
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXX-XX");
} catch(err) {}</script>
<script type="text/javascript" src="/script/gaAddons.js"></script>

That’s it. Now just wait 24 hours, for the first couple of event to take place, and then it will appear in your report under Content >> Event Tracking. The results, will look like something below:

In short, this is an essential script for any site using Google Analytics that needs to know where users go after they leave their site, and what information they download.

Please note: gaAddons is not compatible with the new Google Asynchronous Tracking method. As Stephane Hamel pointed out earlier this year on his blog: “I intend to do a complete rewrite in a more object-oriented form that will easily support async-calls. However… this being an open-source/free project, it tends to fall lower in the list while I focus on consulting, teaching & speaking :)”

Adrian Speyer

About The Author: Adrian has over 12 years experience in Digital Marketing and Analytics. He currently works as a Marketing Manager at Vanilla Forums, a modern forum software platform that allows clients to connect and engage their communities and customers. He lives and works in Montreal.

More Posts - Website - Twitter - Google Plus

Print This Post Print This Post