outbound links in the new version of Google Analytics outbound links in the new version of Google Analytics

How to track outbound links in the new version of Google Analytics

So the Gods of Google have gone and changed their basic Google Analytics code to something that works slightly better, and now your outbound link tracking code doesn’t work.

Here is how you fix that – first make sure you have the most recent (as of July 2013 Google Analytics code, it looks something like this)

<script>
(function (i, s, o, g, r, a, m) {
i[‘GoogleAnalyticsObject’] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, ‘script’, ‘//www.google-analytics.com/analytics.js’, ‘ga’);

ga(‘create’, ‘UA-XXXXXXXX-1’, ‘mydomain.com’);
ga(‘send’, ‘pageview’);

var clientId = ”;
ga(function (tracker) {
clientId = tracker.get(‘clientId’);
});
</script>

 

If it does not look more or less like that, then do not use the code below.

Now make the links you want to track look  like this

<a href=”http://www.SomeOtherDomain.com” onClick=”ga(‘send’, ‘event’, ‘Outbound Links’, ‘click’, ‘http://www.SomeOtherDomain.com’)” target=”_blank”>www.SomeOtherDomain.com</a>

Note the onclick event – that is the key thing.

 

Where can you see the result?  They do not show up as page views  (like they used to) instead they are treated as “Events”.  To see them, go to (in the main Google Analytics screen)

1.  Standard View

2. Content

3.Events

4. OverView

5. Event Label

And there you are.  Not exactly intuitive, but not bad.

 

 

Written By Steve French

 

Leave a Reply

Your email address will not be published. Required fields are marked *






Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.