Search the Site

Sponsors

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="http://ww2db.com">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="http://ww2db.com" onClick="javascript: pageTracker._trackPageview('/outgoing/ww2db.com');">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.

Update

Updated code based on Google Analytics changes:

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

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