So, I thought I'd make this post as an information post to help people with cloaking their links, and also to stress the importance of tracking your links, rather than leaving it all to the affiliate.
I know that many of you already track your links in "some" sense, there'll be people tracking each individual link on its individual basis, which is great - as you can then spot what any site changes do to each individual affiliate link you have, but I'm sure there are others which don't bother doing it, and just leave it all down to the affiliate itself, and many which are just using a standard doorway page for tracking, without doing any cloaking with javascript.
Cloaking IMO has become far more important with the panda updates, especially if you are looking to drive lots of search traffic to your affiliate site, as opposed to using PPC, social media or other traffic sources.
Google seems to be devaluing blatant affiliate sites, so it makes sense to make your affiliate activities as hidden as possible from Mr Googlebot, to minimise the risk of bots picking up on you being an affiliate, and potentially penalising you for it in the SERPs. I'm not saying that Google definitely do do this, but it's better safe than sorry, right?
Now, for all my tracking I use Google Analytics. You might choose to use a different piece of tracking software, but for the purposes of this article I'll be dealing with GA in particular.
First things first, you need to have a webpage setup as a gateway page, preferably in its own directory. This script can be really simple, and is just used to determine where to send the visitor off to. I use something like this, in PHP:
Script: /links/go.php
I appreciate that some of you won't know PHP, but the above code is so simple that anyone could get the jist of what it's doing in 30 mins if they cared, just start here: PHP Introduction
Here's what the script does in layman terms:
1) visitor goes to yoursite.com
2) They click an affiliate link on your site, which redirects them to yoursite.com/links/go.php?i=1
3) Script above checks the value of "i" from the URL, and redirects them to the correct URL. In this case, 1 is: url1.com, so the URL inside of the case statement.
If you really cba, just use a standard affiliate link traffic script.. Lots of them do far more than you need though when you've got GA, and will create additional server load.
Once that's setup, block the entire /links directory (or whatever you decided to call it) in your robots.txt file. Like so:
Make sure that go.php is the only file in the /links/ directory, to avoid accidentally blocking other website files you may want google to index. This stops Google from trying to access the page / follow where you're externally taking the visitor. Google "could" potentially ignore this, but search engine's aren't supposed to go and visit blocked pages at all.
Next, you need to create a new file in /links called script.js, so in the same directory as go.php. Again, this assumes you are using google analytics. The code is as follows:
Then, in the footer of every single page on your website, just before the closing body tag, add the following:
Technically you could put this anywhere on the page after your main Google Analytics code you use (i.e. the code that Google tells you to copy paste onto your site). But I always recommend placing JS at the bottom of the page where possible, to minimise site loading times.
Next, you want to start cloaking your links, so rather than redirecting your user in the traditional way, i.e.:
You now need to do the following:
and that's it. You can then swap "Herp Derp" and "Herp Derp Sidebar Link" in the code above to match whatever you want to track, so for example if you were selling Acai Berries. (Oh shit, sorry to out that niche guys), then you might go with "Acai Berries" for the first in quotes, and "Acai Berries Sidebar Link" for the second. This means that you can track how individual links are performing on your site. You might then add a link to your content for example, which you could do: "Acai Berries" and "Acai Berries Amazing Article No. 1 Link" - this way your "Acai Berries" can be used to track how your Acai Berries campaign is performing as a whole, and your second tracking can be used to break it down further, and see which of your individual links are performing the best, and so on.
In the above example, in Google Analytics, under "Events", "Acai Berries" would show up as the event category, and "Acai Berries Sidebar Link" would show up as the "Event Action". This means you can do cool things too, like determine the CTR for individual links from different traffic sources. So you can soon find which traffic sources generate you the best CTR, etc.
Your links are now all cloaked from Google's praying eyes too, leaving you with a harmless, unmonetised information site (at least in Google Bot's eyes
).
I've not talked about tracking from the affiliate end, but you want to make sure to use individual trackers for each link position too, so that you can find out whether particular links convert poorly for some reason too despite having high CTRs, to work on improving that, and determine "why" a particular link performs badly (it's usually because the link is in some sense misleading, or trying to trick the user).
Hope that this helps. Please don't PM me asking me questions, but feel free to ask any in the thread and I'll try to help. Hope that this has helped one or two people out there.
Also, I'm well aware that this method will stop people from being able to click your links if they don't have JS installed, or available (hence why it firmly stops mr googlebot in its tracks). But so many websites rely on JS to fundamentally function now-a-days, I just don't see it as much of an issue. Certainly changing over to this method has had no measurable impact on my campaign performance.
Also, in before this page ranks #1 for Acai Berries in google.
I know that many of you already track your links in "some" sense, there'll be people tracking each individual link on its individual basis, which is great - as you can then spot what any site changes do to each individual affiliate link you have, but I'm sure there are others which don't bother doing it, and just leave it all down to the affiliate itself, and many which are just using a standard doorway page for tracking, without doing any cloaking with javascript.
Cloaking IMO has become far more important with the panda updates, especially if you are looking to drive lots of search traffic to your affiliate site, as opposed to using PPC, social media or other traffic sources.
Google seems to be devaluing blatant affiliate sites, so it makes sense to make your affiliate activities as hidden as possible from Mr Googlebot, to minimise the risk of bots picking up on you being an affiliate, and potentially penalising you for it in the SERPs. I'm not saying that Google definitely do do this, but it's better safe than sorry, right?
Now, for all my tracking I use Google Analytics. You might choose to use a different piece of tracking software, but for the purposes of this article I'll be dealing with GA in particular.
First things first, you need to have a webpage setup as a gateway page, preferably in its own directory. This script can be really simple, and is just used to determine where to send the visitor off to. I use something like this, in PHP:
Script: /links/go.php
PHP:
<?php
$linkId = (int) $_GET['i']; // (int) is an extra safety thing, removes any risk of XSS by converting GET data to an integer.
switch($linkId)
{
case 1: goTo("http://url1.com"); break;
case 2: goTo("http://url2.com"); break;
case 3: goTo("http://url3.com"); break;
// Add more cases as you go on, depending on the number of unique links you are tracking. Simply replace "http://url1.com" and so forth, with the affiliate urls you are going for. The corresponding case # is the # you use in the URL for that particular affiliate tracker.
}
function goTo($url)
{
header("Location: $url");
// You can also do some click logging here if you want, as an extra precaution, but if you've got a high traffic site, logging all this to SQL etc could result in high DB loads
}
I appreciate that some of you won't know PHP, but the above code is so simple that anyone could get the jist of what it's doing in 30 mins if they cared, just start here: PHP Introduction
Here's what the script does in layman terms:
1) visitor goes to yoursite.com
2) They click an affiliate link on your site, which redirects them to yoursite.com/links/go.php?i=1
3) Script above checks the value of "i" from the URL, and redirects them to the correct URL. In this case, 1 is: url1.com, so the URL inside of the case statement.
If you really cba, just use a standard affiliate link traffic script.. Lots of them do far more than you need though when you've got GA, and will create additional server load.
Once that's setup, block the entire /links directory (or whatever you decided to call it) in your robots.txt file. Like so:
Code:
User-agent: *
Disallow: /links/
Make sure that go.php is the only file in the /links/ directory, to avoid accidentally blocking other website files you may want google to index. This stops Google from trying to access the page / follow where you're externally taking the visitor. Google "could" potentially ignore this, but search engine's aren't supposed to go and visit blocked pages at all.
Next, you need to create a new file in /links called script.js, so in the same directory as go.php. Again, this assumes you are using google analytics. The code is as follows:
Code:
function passthru(category, action, url) {
_gat._getTrackerByName()._trackEvent(category, action);
setTimeout('document.location = "' + url + '"', 100);
}
Then, in the footer of every single page on your website, just before the closing body tag, add the following:
Code:
<script type="text/javascript" src="/links/script.js"></script>
Technically you could put this anywhere on the page after your main Google Analytics code you use (i.e. the code that Google tells you to copy paste onto your site). But I always recommend placing JS at the bottom of the page where possible, to minimise site loading times.
Next, you want to start cloaking your links, so rather than redirecting your user in the traditional way, i.e.:
Code:
<a href="http://www.yoursite.com/links/go.php?i=1">BUY HERP DERP NOW! YOU'LL LOSE 400LBS in 7 DAYS FOR ONLY $2.95!!!!</a>
You now need to do the following:
Code:
<span onClick="passthru('Herp Derp', 'Herp Derp Sidebar Link', 'http://www.yoursite.com/links/go.php?i=1');return false;" style="cursor:pointer">BUY HERP DERP NOW! YOU'LL LOSE 400LBS in 7 DAYS FOR ONLY $2.95!!!!</span>
and that's it. You can then swap "Herp Derp" and "Herp Derp Sidebar Link" in the code above to match whatever you want to track, so for example if you were selling Acai Berries. (Oh shit, sorry to out that niche guys), then you might go with "Acai Berries" for the first in quotes, and "Acai Berries Sidebar Link" for the second. This means that you can track how individual links are performing on your site. You might then add a link to your content for example, which you could do: "Acai Berries" and "Acai Berries Amazing Article No. 1 Link" - this way your "Acai Berries" can be used to track how your Acai Berries campaign is performing as a whole, and your second tracking can be used to break it down further, and see which of your individual links are performing the best, and so on.
In the above example, in Google Analytics, under "Events", "Acai Berries" would show up as the event category, and "Acai Berries Sidebar Link" would show up as the "Event Action". This means you can do cool things too, like determine the CTR for individual links from different traffic sources. So you can soon find which traffic sources generate you the best CTR, etc.
Your links are now all cloaked from Google's praying eyes too, leaving you with a harmless, unmonetised information site (at least in Google Bot's eyes

I've not talked about tracking from the affiliate end, but you want to make sure to use individual trackers for each link position too, so that you can find out whether particular links convert poorly for some reason too despite having high CTRs, to work on improving that, and determine "why" a particular link performs badly (it's usually because the link is in some sense misleading, or trying to trick the user).
Hope that this helps. Please don't PM me asking me questions, but feel free to ask any in the thread and I'll try to help. Hope that this has helped one or two people out there.
Also, I'm well aware that this method will stop people from being able to click your links if they don't have JS installed, or available (hence why it firmly stops mr googlebot in its tracks). But so many websites rely on JS to fundamentally function now-a-days, I just don't see it as much of an issue. Certainly changing over to this method has had no measurable impact on my campaign performance.
Also, in before this page ranks #1 for Acai Berries in google.