Google Analytics does not track links to external sites, nor does it track non-pageview events such as file downloads. For most sites, these are pretty valuable metrics that should be tracked. Many people deal with this by manually adding onclick code that calls the _trackPageview function to all of their links. At best, this is time consuming, at worst it is error prone and many links get forgotten.

There are several ways to automate this so that the these external and file download links will get tracked by Google Analytics without the need to add code to every link. One way is to use javascript to add the _trackPageview event to all of the links that need it, dynamically, when the page loads. This ensures that all of links on the page get the proper treatment. This is especially important if you are using some form of CMS where some of the links are likely to be in the content, while others are in the templates. Brian Clifton has a javascript on his site that does just that: Updated auto tracking script for file downloads, outbound links and mailto links

In my experience, this method works quite well, and it takes just a few minutes to implement.

Leave a Reply

Your email address will not be published. Required fields are marked *