Better Affiliate Link Cloaking for SEO

Not to be confused with referrer cloaking, cloaking affiliate links is typically done to present a nice looking URL to the user. The idea is, the savvier visitor might see a weird URL in the browser status bar and be less likely to click—so it’s best to cloak the link. If you’re using this technique for a landing page that you’re driving paid traffic to, then one of the usual link cloaking methods is fine.

Cloaking affiliate links on a niche site or datafeed site that’s relying on organic traffic is a different ballgame. A big part of doing this successfully is avoiding duplicate content issues and being pegged as an affiliate site with no added value. Unless you’re retarded you’re already mixing up and/or adding some value to the stock content provided by the merchant, but one problem remains…

When a search engine spider follows your out links, it will see them route through an affiliate network then to the merchant’s site. It’s easy to see that this can be used to identify your site as an affiliate site and therefore bury it in the SERPS. So what can you do?

The Solution

My epiphany happened when I was reading Rae Hoffman’s post about datafeed sites. Among the tips she offers is one that made a light bulb turn on in my head:

Run your links through a blocked folder. Genius!

To make this work, first create a directory in your site’s html root directory (usually “public_html”). You can name this directory anything. In this example, I’m going to name my directory “store”.

The Redirect Script

In this new directory “store”, create an index.php file with the following code:

1
2
3
4
5
6
7
8
<?php
// simple redirection script
// pass a get variable 'item=' with value that's urlencoded and base64 encoded
$item = $_GET['item'];
$url = urldecode($item);
$url = base64_decode($url); 
header("Location: $url");
?>

This code is designed to accept a URL passed using the “item” variable and then redirect the visitor.

The Encoder Script

This next bit of code is how you encode your links.

1
2
3
4
5
6
7
8
9
10
11
<?php
// Simple base64 encoder
// Enter your affiliate link here
// e.g. $url = "http://www.shareasale.com/m-pr.cfm?merchantID=12345&userID=77777&productID=123456789";
 
$url = "http://ctrtard.com/";
 
$url = base64_encode($url);
$url = urlencode($url);
echo $url;
?>

We encode the URL for the sole purposes of making it not look like an obvious affiliate link. For niche mini sites, you can just use this code to encode your links one at a time before placing them in your blog. For larger sites that have many affiliate links, you’ll want to incorporate this into your site building scripts to encode all the links before generating the html.

Robots.txt

The final thing you will want to do is setup a robots.txt file and place it in your site’s html root directory (public_html) that contains the following:

User-agent: *
Disallow: /store/

Usage

In the above example, the URL I chose to encode is “http://ctrtard.com/” . The encoded version of this URL is this:

aHR0cDovL2N0cnRhcmQuY29tLw%3D%3D

So to use this, you’re link would be:

http://yourdomain.com/store/?item=aHR0cDovL2N0cnRhcmQuY29tLw%3D%3D

When the visitor clicks on the link, they will get redirected through your affiliate URL to the merchant’s site. The search spiders, on the other hand, won’t ever follow this link. That’s because they’re obeying the rule you set in your robots.txt file that tells them they are not allowed to spider anything in the “/store” directory. This prevents the search engines from indexing many links to a merchant and realizing you’re simply an affiliate for XYZ merchant.

Sweet! You’ve just avoided leaving yet another fingerprint that says you’re a an affiliate site and gained a little advantage over the competition.

Pro Tip

There is no reason you can’t add on dummy variables to your links. The redirect script above only cares about the value of “item”. You can easily add other dummy variables to make your links look different. For example:

http://yourdomain.com/store/?show=product-details&item=....
http://yourdomain.com/store/?zoomlevel=large&item=....

In both of these above cases, the “show” and “zoomlevel” will be ignored by the redirect script, but you still get the benefit of having it look like the on-page links are different.

Leave a comment

Leave a Reply to Josh M Cancel reply.

*

*

CommentLuv badge
Cancel reply

22 Comments

  • Elegant simple and clean… Robots.txt-disallowed directory. Nice one!

    • Thanks, I thought the same thing when I saw Rae’s tip. Thanks for reading!

  • Awesome tip. I’ve been hacking out a few amazon niche stores and since I’m rolling through them I was not taking time to change the links or put them all in a php file. Maybe I’ll do this though.

    • Yeah you should try it. I’m rolling out a bunch of sites this week hoping to get a little of the holiday spend. I’m going to use this method on all of them and see how it stacks up to my other sites.

      Thanks for reading!

  • Never thought of that. This idea is simple but awesome. I’ll implement in my websites. Just wonder if all the major search engines follow the rules in robots.txt?

    • Yes, the major searching engines (Google, Bing, Yahoo) all support it without a doubt. It’s the smaller ones and the shady bots that do not. But who cares about those guys, right?

      Thanks for reading & commenting!

  • Adam Gatenby

    Many thanks for your examples. I have already got a similar PHP page on my affiliate site which passes a product and store id and then redirects through that. I’m really trying to improve my SEO and page rank. It would be good to hear any other tips of the trade you have to offer. It sounds like google really don’t like affiliate links! Thanks again.

    • As for other tips, I’m testing some stuff out with some new sites. I’ll be sure and post anything good I find.

      Thanks for reading and comment!

  • Thanks for the link cloaking tip, after doing strictly SEO for a number of years I got suspicious of Google detecting affiliate links and having an affect on my SE results. I also developed a method of cloaking links to make the search engines think I was linking content without affiliate links. My thoughts is that Google likes when you link to other valuable websites but not when your making money. Here’s my link hooking technique: http://www.mrtemple.com/code/link-hook-technique/

    Check it out and let me know what you think or how it could be better 🙂

  • Hmm… seems like it would work to me, unless google runs simple js action handlers. And if they do, you could just obfuscate with a more complex js function.

    Eric

    • Yeah I guess it’s possible they do that. So far this seems to keep me off their radar. Thanks for reading!

  • MrMatts

    hey There This script looks cool. Im trying to use it but I run into some problems…. Are you supposed to use 2 different scripts index.php and encode.php or something similar?

    I cant get the script to redirect? Or should all code be inside index.php? Sorry Im not so sharp with Php?

    • As I wrote above, the redirect script goes into a blocked folder/directory and is named index.php.

      The encoder script provided is an example of how to encode the links so you can then pass them to the redirect script. You can use this bit of code stand alone (like visit it in your browser) and you will see what your link looks like encoded. This encoded form of your link is what you pass to the redirect script.

  • Thank you for the tip, specially the robot.txt one

  • Thanks for the tip. I am not sure about how encoding would help in this case. We assume they don’t follow the link. What difference would it make for search engines if we use it like

    ?item=aHR0cDovL2N0cnRhcmQuY29tLw%3D%3D

    or

    ?item=1 (or any number here)

    or

    ?item=1&moredummy=abd452c

    • The purpose of encoding is to obfuscate any hints that could be in the link code itself. Consider something like a data feed site full of links. If you did this:

      http://yourdomain.com/store/?item=http://shareasale.com/affid=x&affprogram=y

      It would be a simple matter for the SE to detect a known affiliate link being passed as a parameter. The only way to avoid that is to obfuscate it.

      From there, as long as they don’t follow the link (and the major SE’s DO obey the robots.txt file) they have no way of knowing you are linking out to an affiliate program.

      In your example, you are passing “item=1”. That in and of itself is kind of obfuscation because “1” means nothing. Your redirect script would have to know where to send the browser if it sees a “1”. You *could* do that, but then you’d have to setup and maintain a list of redirects, etc. And we’re aiming for quick and efficient, set and forget here 🙂

      Thanks for reading!

  • Thanks for the lengthy response. I see your point more clearly now.

  • Ok, I realize this is an old post…, but since we’re, “retards”, I just wanted things explained a little clearer, lol.

    If you could just explain in a little more detail on how to edit the scripts. I have a little knowledge in redirect scripts, I’m guessing in the first “redirect script”, on this line:

    $item = $_GET[‘item’];

    you replace: ‘item’ with your affiliat url, and in the “encoder script, on this line,

    $url = “http://ctrtard.com/”;, we put the link we want our visitors to see & visit. Then just upload the robot.txt file as well.

    Is this correct?

    Thanks for the great site, just that some of us “retards”, need a step by step, do this do that explanation…lol.

    P.S.- Some video tutorials would be awesome too!!!
    😀

  • Josh M

    Just to clarify, for every affiliate link you create to a different, separate page, would you need to create a new index.php file in the /store/ directory, except calling it another name?

  • Hi ctrtard,
    Can you tell me how to cloak affiliate link like this http://www.nthemes.net/elogix-premium-responsive-theme/
    I dont think its same your tip.
    Thanks.

  • Do you know how to hide the affiliates link if we promote using FB ads because I’ve tried using tiny url on FB ads but the preview will display vendors domain name, I want like this (somebody has post their ads on FB like this) :

    ads title
    picture of the ads
    en.wiki.org

    when we click the ads or the link it will bring us direct to clickbank landing page/vendor LP so how I can make that en.wiki.org appears on my FB ads? it must be use special script, do you have any suggestion? thanks.

 
 
 

Related posts by category

Related posts by tag