Link Cloaking

Way back when, “link cloaking” referred to a Black Hat SEO technique (a way to get high rankings on search engines). I won’t go into the technical details, but basically the web page sends different information to the visitor based on who they are. In short, if the server detects that you are Googlebot (Google’s search indexing system which ranks content relevance) it displays “nice” information. This “nice” information would rank well, and consequently the site would be one of the first ones displayed in the search results). However, if the server detects that it is a human (i.e. you!), it displays “other” information (usually trying to sell you something). While an interesting topic in itself, that’s not what this post is about :)

Originally known as “affiliate link cloaking”, it has now replaced the Black Hat SEO technique as the assumed definition of “link cloaking”. As an example:

If you click on the links above, both will take you to www.google.com.
But you’ll notice that the cloaked link doesn’t display the same information on the bottom-left of your browser.
Uncloaked linkCloaked link

There are many reasons why someone might want to cloak a link. The most common reason is for affiliate sales (where the affiliate gets a commission if they refer someone who ultimately makes a purchase). Under these circumstances, link cloaking does the following:

  • Obscures the sale (so that you might not immediately know that you’re going to be buying widgets from company XYZ, until you actually click on the link and go to the XYZ’s site).
  • Prevents you from “bypassing” the affiliate (where you remove the affiliate’s code and go “directly” to XYZ’s website). Doing so won’t actually save you any money. But because the seller won’t know which affiliate referred you, the affiliate loses out on the commision.

Anyway, without further ado, here is the code of my link.php file.

<?php
$path = array(
'123' => 'http://www.google.com'
);
$key = htmlspecialchars($_GET['key']);
if (array_key_exists($_GET['id'],$path))
header(’Location:’.$path[$_GET['id']]);
?>

Basically, this file compares the ID paramter (e.g. www.wandering.net/link.php?id=123) against the array. If a match exists (”123″ in this case), then it uses the PHP Header Location call to redirect the browser (”www.google.com” in this case).

To use, just change the HTML A (link code) from

<a href=”http://www.google.com”>This is an uncloaked link to Google</a>

to

<a href=”http://www.wandering.net/link.php?id=123″>This is a cloaked link to Google</a>

Simple :)

Comments
There are no comments just yet, why not be the first?
Leave a Comment
Add your picture!
Join MyBlogLog and upload your avatar. C'mon, it's free!