Home > Code > Hiding Affiliate Links

Hiding Affiliate Links

January 31st, 2010 Leave a comment Go to comments

First off, you do have a responsibility to disclose affiliate links but I think it is a requirement also, to instruct web bots to ignore these links and to clean up the URL of the link to remove your affiliate details.

Copy and pasting the actual affiliate link that you are given directly to your site is not a good idea since it will look unprofessional, it will be a weird kind of link that will show up when your visitor hovers their mouse over it and it may give people easy clues for how to bypass your affiliate link and go direct to the recommended product site.

What I and many other affiliate marketers do is have a URL stub of say “goto” or “recommends” followed by a keyword for the product such as:

goto/theaffiliatecode

So in this case I might be recommending The Affiliate Code to my readers and provide them this highly relevant link that integrates neatly with my website.

So how do “I” do this Andrew? Glad you asked …

One way is to have a .htaccess file which works with the Apache web server which most Linux hosts run.

In this text file we place code like this:

RewriteEngine On
RewriteRule ^goto/theaffiliatecode$ myAffiliateLink [L]
 

And save it to the root of our website with the name of .htaccess (since it is a hidden file, there is no file extension such as .txt).

Test this link

You may already have this file on your server so add this code before the other entries in the file.

Use a text editor such as NotePad++ to do this.

In my example, replace myAffiliateLink with, you guessed it! Your affiliate link URL.

The code works like this:

The RewriteEngine module of the web hosting is turned on so that the URLs that are published on your site can be redirected to another URL.

So the second line performs this redirect when the URL matches a pattern specified in the first parameter of the line of code.

The ^ and $ mark the beginning and end of the pattern and goto/ is our URL stub followed by theaffiliatecode which was my chosen keyword to use for this URL. The second parameter of the redirect is the destination URL, i.e. our affiliate link.

To add more affiliate links you would just add them in the same way on a new line after the last redirect e.g.

RewriteEngine On
RewriteRule ^goto/theaffiliatecode$ myAffiliateLink [L]
RewriteRule ^goto/dogtraingtips$ myDoggyTipsAffiliateLink [L]
 

The [L] instructs the web server to treat the redirect as the last rule to check if there is a match.

I go a step further than this using my own script that manages affiliate links. So I can track the clicks and don’t have to keep editing my .htaccess file to add new links.

You can download the link manager here. This tool also incorporates a couple of other ways to hide an affiliate link which I don’t tend to use since they may result in violation of affiliate terms and conditions of participation.

The first method is framing of the landing page. This is a simple technique where the landing page is contained inside an HTML frame. However, Ad-blocking software on people’s computers may render the web page invisible! Anyway, this method is obsolete now since product vendors are starting to use cookies to log referring affiliates and are stripping off the affiliate id from the URL once the cookie has been saved. I will cover the important topic of cookies in another post, so make sure you subscribe in some way to this site!

The next method is “cloaking” which involves removing traces of the origin of the initial click. This is mainly to hide which keywords were used to land on your pre-sales page. Mainly of interest to PPC (Pay Per Click) affiliates that want to hide which keywords they are bidding on from their affiliate network. The keywords are often propagated to the landing pages so as to allow for conversion tracking.

So the cloaking works by having an intermediate web page that logs the click-through data and then redirects to the final landing page minus this data and minus the referring page information.

Also, cloaking may be of interest to marketers that want to hide the location of their Ads.

Finally, block web bots from following your affiliate link path. Please see my last post on SEO and Web Bots for how to do this.

So hopefully that gives you a nice over-view of the art of ethically hiding affiliate links.

If there is any area of confusion that you would like me to clarify, please comment …

Post to Twitter

Categories: Code Tags:
  1. No comments yet.
  1. No trackbacks yet.

CommentLuv Enabled