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

6 Responses

  1. Hey! Thanks for the mention! And you will be happy to know I’m working on v2.0 of this script, which will support the new async calls, make it easy to tweak options and include several other interesting hacks.

    Regards,
    Stéphane

    • Stephane,

      I was extremely happy to find this script and wanted to help spread the word. Funny, I was just thinking that the only down-side was that the necessity to use this script would prevent me from moving to the new async tracking code – so it is great to know you are working on a new version.

      Really appreciate your work on this and sharing it with the community.

      Regards,
      John

  2. This looks like just what I need.

    Does it matter what kind of Java framework your site is using. For example — MooTools?

  3. What does this mean? “Should be set to the name of your tracker variable” where it says gaA_pageTracker=true;
    ?? Where can I find my tracker variable name. Thanks!

  4. Good post… I’m always on the lookout for good blogs.

  5. I hardly comment, however I browsed some remarks here Tracking Outbound Links the Easy
    Way with Google Analytics | Catbird Analytics.
    I actually do have some questions for you
    if it’s allright. Could it be only me or do a few of the remarks look like they are left by brain dead people? 😛 And, if you are posting at additional online social sites, I’d like to keep up with everything new you
    have to post. Could you make a list of all of all your social networking
    sites like your Facebook page, twitter feed, or linkedin profile?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: