Search the Site


bottom corner

Tracking outgoing links with Google Analytics

This note describes one way to use Google Analytics to track traffic going out of your site via links you provided.

This page is filed under keyword(s): analytics.

Normally, a link's HTML code looks like the following.

<a href="">World War II History</a>

If you are using Google Analytics, you know that you can easily see what site is referring traffic to your site. But how do you use Google Analytics to track traffic flowing the other way? One way you can do so is by calling the ._trackPageview() method in Google Analytics' pageTracker object. For example:

<a href="" onClick="javascript: pageTracker._trackPageview('/outgoing/');">World War II History</a>

Now whenever someone clicks on the World War II History link, it will be tracked as a normal visit to a particular content page. To see this data, log on to Google Analytics and go to Content, then Top Content, and finally search for all URLs containing the word "outgoing". By the way, you can name these mock content URLs whatever you want. I chose to use the word "outgoing" because no other pages in my site contains the word "outgoing", thus making it easy to distinguish between normal content and outgoing content.


Updated code based on Google Analytics changes:

onclick="javascript: ga('send','pageview','/outgoing/');"

Did you find this page useful? Please consider browsing other articles or subscribing to the RSS feed to keep up with latest.

This page is filed under keyword(s): analytics.
Author: C. Peter Chen
Last updated: 26 Jul 2016

bottom corner