Outbound links in Google Analytics: Brian Clifton’s scripts revisited

Posted on May 19, 2009

Brian Clifton has published an awesome script to track outbound links. We were early and avid users of this. However, over time, some limitations have appeared.

Back to last year, Julien Bissonnette, a fellow web analyst here at Magnet, first contacted Brian with a fix to detection of existing GA code in the onclick event, with IE. Since then, we have worked a lot on the script to finally get a completely revisited script. Several limitations have been fixed, including:

  • Fix a bug with onclick attribute handling with IE that prevent any data to be collected with IE,
  • Track links within <area> tags,
  • Better exit link detection: do not track when no href attribute is present, or when exit is managed with Javascript in the onclick attribute, and so on…,
  • Track a download link on an external server as a download instead of an exit,
  • Collect data with a customizable function.

How do I install it?

  1. The very first thing you need to do is to download Javascript file.
  2. Include the script somewhere in your HTML pages:
    <script src="script/ga-links.js" type="text/javascript"></script> 
  3. Call the script at the very bottom of your pages, just before the </body> tag:
    <script type="text/javascript">
    var extTrack = ["127.0.0.1","example.com"];
    var extDoc = [".doc",".xls",".exe",".zip",".pdf",".ppt"];
    addLinkerEvents(”pageTracker”, extTrack, extDoc,”"); 
    </script>
  4. Complete the list of domains and extensions to track. Make sure to review 1st parameter of addLinkerEvents function, according to your own implementation.
  5. Edit function customLink within Javascript file to grab data the way you like. As an example, you might want to use event tracking.

What’s in it for me?

If you keep the Javascript file “as is”, you should create a profile that use an exclude filter on Request URI to filter out “utm_action=(download|mailto|exit)”. This way, you have a clean profile without extra page views if it’s important to you.
Additionally, you should set site search as follow in order to get outbounds within site search reports.

sitesearch

As a result, you will have these kind of report:

site-searchreport

Obviously, you can drill down within each type of link to get the detail of each download, exit or mailto. An advantage of doing this is that you can analyze the impact of a type of link, or a specific link on your defined goals. A typical case would be the impact of downloading a document in a specific conversion funnel.

Depending on your website objectives, you might want to setup some goals as well. Simply create a regular expression goal with “utm_action=exit” or “utm_action=mailto”.

This post was written by Alex

Tags:

Leave a Reply

Featured Clients

Magnet Search Marketing clients

Featured Case Study

Advanced Paid Search Strategies

GM Optimum’s inventory is very broad and can contain more than 500 different models at any time. It quickly becomes challenging to manage the keywords to fit only the available car models.

Read more