BBC External Link Tracking Script

by Patrick Altoft on / 5 responses

Since my post about the BBC blocking the link juice on external links they seem to have come up with a very clever piece of JavaScript to get around the issue. It’s not on all the external links but it’s on some of them.

Links are still clean and there is nothing in the source code to indicate that they pass through a redirect. However when you click on any external link users are still sent through a tracking script.

This might be a very useful script for some of you who want to track links but still pass SEO benefits, the original is here. For a demo visit this page and click the “Movie Review Query Engine” link.

var LinkTrack = function ()
{
this.docLinks = document.links;
this.location= location.pathname;
}
LinkTrack.prototype.updateHrefs = function ()
{
var currlink, hostname, protocol, linktext;
if (!(!document.getElementsByTagName && document.all))
{
for (var i=0; i {
currlink = this.docLinks[i];
hostname = currlink.hostname ? currlink.hostname.toLowerCase() : "";
protocol = currlink.protocol.toLowerCase();
linktext = currlink.innerText;
if (protocol == 'http:' && (hostname != 'bbc.co.uk' && hostname.indexOf('.bbc.co.uk') == -1))
{
currlink.href = this.getNewUrl(currlink.href);
if (document.all && currlink.innerText.toLowerCase() == currlink.href.toLowerCase()) currlink.innerText = linktext;
}
}
}
}
LinkTrack.prototype.getNewUrl = function (destination)
{
var newUrl = '/go';
newUrl += this.location;
newUrl += (newUrl.substr(newUrl.length-1) == '/')? 'ext/_auto/-/' : '/ext/_auto/-/';
newUrl += destination;
return newUrl;
}
var myC = new LinkTrack();
myC.updateHrefs();

Patrick Altoft is Director of Search at Branded3, a Leeds SEO & Digital Agency specialising in SEO, Web Design, Development & Social Media.

Get daily posts direct to your inbox

You can get our blog posts delivered for free by email every day - simply add your email address to the box above, or alternatively you can grab the RSS feed.

Comments

Read the 5 comments below, or add your own!

February 11, 2009 at 6:24pm

It is still and always has been, a huge security issue for the BBC. Do you think this will make them change it ?

http://www.bbc.co.uk/go/redirect.shtml?javascript:alert(document.cookie)

Reply

February 12, 2009 at 2:42pm

Good to see that your post has perhaps had some good benefit at the BBC, were you the only person to highlight the issue at the time? Or the first to mention and it became a larger issue at the BBC?

Reply

February 13, 2009 at 2:00pm

Thanks a lot.

Reply

anon
May 11, 2010 at 6:45pm

actually, there never was a problem, try going to one of the /go urls while changing your user agent to one of a search engine, e.g. ‘Googlebot/2.X (http://www.googlebot.com/bot.html)’.

excuse my anonymity, but you might like to check facts.

Reply

October 14, 2011 at 8:24am

BBC is as strict as always, but this external link tracking script seem to solve the problem. I have always wanted to track links properly. This is a very post indeed, thanks!

Reply

Leave a comment

Your email address will not be published. Fields marked with an asterisk are required.
 

  *

  *

You can use one of the following tags:
<a href=""><blockquote><code><em><strike><strong>