How do I track Outgoing Clicks from my website using Google Analytics?

I use google analytics to track users on my website. I want to track which outgoing links they click on. I know this can be done using analytics, but am not able to get this to work. Can someone please help me.

Can you answer this question?

Raghav Kapur
Raghav Kapur
  • Answer written
  • 2 Years ago

Tracking outgoing links is possible using Google Analytics - However to do this, you to update the script and all the links that you would like to track. 

Assuming you are using the analytics.js tracking code (released in 2012), all you need to do is add a script below your google analytics script on the pages where you wish to track out going links. You will also need to add an ‘onclick attribute to each link that you would like to track.

Add this script below your google analytics code:



var trackOutboundLink = function(url) {

   ga(send, event, outbound, click, url, {hitCallback:

     function () {

     document.location = url;






This script will track a click on an outbound link in Google Analytics. This function takes a valid URL string as an argument, and uses that URL string as the event label.

You will also need to add (or modify) the onclick attribute to your links. Here is an example:

<a href="" onclick="trackOutboundLink(; return false;">Check out</a>

You can view these clicks under the event tracking section of google analytics. This will be under the Behavior Tab. 

A few things to note:

Every outgoing click will be added to your page view count. So if you want to track the actual number of page views that you have, you will need to subtract this number from the total page views displayed.

More information about this can be seen on


Related Questions

Product Information