Tracking Outbound Links the Easy Way with Google Analytics

Stephane Hamel at Immeria offers an elegant solution to a cumbersome problem

Google Analytics is, of course, a powerful tool for measuring onsite performance and supporting decisions around how to improve better results. For one thing, you can easily get a bead on where visitors are leaving your site just by checking the ‘Top Exit Pages‘ report.

Exit Pages ReportHigh % of exits may be fine for a goal completion page (‘thank you’ for your order) but may not be so good when it is your home page, as in the example to the right, and almost 80% of visitors to the page are exiting from there. So we would want to look at this page and see what can be done to increase the stickiness to the site.

With all its power, one thing Google Analytics can’t tell us is where those who leave the site from this page are going, even if they are using exit links on our site. At least not out of the box (the same is the case with most web analytics platforms). For example, in the case shown in the screenshot, it turns out that there are several major calls to action on the site’s home page that lead off-site. It would be very helpful to know which, if any, of these links are being followed by visitors.

Now, I know what you’re saying: easy – either tag them as virtual pageviews ( onclick=”pageTracker. _trackPageview(‘/Exit-Links/www.example.com’);” ) or apply event tracking. Which is fine, except that it has to be done on a link-by-link basis. That may be okay when you have a couple of featured links on a home page, but I have another site that acts as somewhat of a portal to breweries in British Columbia, with tons of links to other sites. Hand-coding dozens of links is not my thing (and this is a small site).

But Stephane Hamel has come to the rescue with some tidy GA Javascript that automates the process of tracking outbound links and/or file downloads in Google Analytics across your site.  All you need to do is:

  1. Grab this Javascript file and place it on your server.
  2. Add this Javascript line below your GATC (with appropriate reference to the Javascript file location):

Additional line of Javascript below GATC

One other thing you may want to do: check the Javascript file to see if you want to change the settings that determine whether outbound links and downloads are tracked as virtual pageviews or events. The default is to track both as events, which may work for you.  Depending on the content, I generally prefer to track outbound links as events (I don’t want them inflating my total pageviews) but track downloads as pageviews (on the basis that a pdf product spec sheet is, in a sense, a ‘pageview’ of a different kind.)  The added advantage of using pageviews is that they can be tracked as goals.  If you want to change either of these settings, look for this area in the code and make changes accordingly:

Settings in gaAddons Javascript file

There, that was easy. Now I can see which exit links visitors are using most often, which opens up all kinds of opportunities for content development, partnerships, etc.:

Event report showing exit links

This has just been turned on a couple of days ago, but I’m already getting an idea of who I should go talk to about getting some free beer! 🙂 And depending on how that works out, I’ll be able to assign value to this event.

Advertisements