BBC External Link Tracking Script
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();
Comments
-
http://www.strangelogic.com Jason Duke
-
http://www.zath.co.uk Zath
-
http://www.top-web-templates.com Raphael@Top Web Templates
-
anon
-
http://www.agriya.com Jon Clone
Latest from B3Labs
- Another milestone reached for Branded3 as it’s acquired by the
St Ives Group - The latest media consumer findings & what they mean for digital marketers
- Talk to Branded3 at @BuyYorkshire in Leeds next week!
Latest from Blogstorm
- Why your press releases are getting you penalised
- After five years, Google still doesn’t know how to rank images
- Tickets now on sale for the next #B3Seminar in London – book now!
