How To Cloak An Affiliate Link

by Clint Maher on June 25, 2009

http://clintmaher.com/wp-content/plugins/sociofluid/images/digg_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/reddit_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/delicious_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/google_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/facebook_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/sphinn_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/mixx_48.png http://clintmaher.com/wp-content/plugins/sociofluid/images/twitter_48.png

Cloaking An Affiliate Link With PHP

There comes a time when you may want to put up an affiliate link on your site, and this is normal for Internet Marketers and Website owners alike. All income streams are welcome, and if you are providing great content and advice, then it is completely acceptable. Of course, there are sites out there that are just spam machines too, although I have little respect for such things. What I want to show you today is how to cloak an affiliate link on your blog, so that it looks like the link is part of your own site, and not an ugly affiliate link or tinyurl. Another reason to do this is so that people will not be able to see the merchant’s link and cut you out of the deal. To do this, you will need only a small amount of technical knowledge.

Video Tutorial On Cloaking An Affiliate Link

YouTube Preview Image

For the purposes of today’s post on how to cloak an affiliate link, I will ‘build’ a real life example of a service that I will promote on this blog. I have my hosting with Mochahost, and they have not let me down in many years of being a client with them, so I feel it’s totally acceptable to give them a plug (with my affiliate link of course).

Log in to your blog or website via FTP, and in the remote pane, we will want to create a new directory. As I want the affiliate link to look like this clintmaher.com/mochahost/ I will create a folder called mochahost. Many people will go one step further, and have the link similar to this, yourdomain.com/recommends/mochahost/ To do this, you will first create the folder named recommends, and then create a folder inside that named mochahost. Easy stuff, so let’s keep going.

Disguising Your Affiliate Link

Assuming you have your affiliate link for the product you are promoting on your site, you will want to open a new text document in a text editor such as notepad. Now, let us save this file (to somewhere you remember) as index.php, although when you save it ensure that you Save as Type >> All Files, and not as a text document. You can do this from the drop down box. Now copy and paste this code in the notepad file, and make sure you put in your affiliate link instead of the fake one in red below:

<?php
header(’Location: http://www.merchantsite.com/aff/idevaffiliate.php?id=831‘);
?>

Save the document again, and it will automatically save as a php file this time.

Jump back into your FTP client such as FireFTP (you are using Firefox I hope?) and put the new file across to the directory you created, and in my case I want it in clintmaher.com/mochahost/

Now comes the fun part and you get to test it to ensure the affiliate link works. Click here to find out. Notice the URL when you run your cursor over the anchored text. Looks so much better than a long and unattractive affiliate link.  Well that’s how to cloak an affiliate link in the easiest way I can describe.

{ 1 comment… read it below or add one }

Justyna @ marketing internetowy January 24, 2010 at 7:29 pm

Thank you for the useful tips:) Especially the given code is pure gold!!
Do you use any plugins to make the whole process faster?

Justyna

Leave a Comment

Previous post: Using Viper Quick Tags To Insert Video Into a Wordpress Post

Next post: Internet Marketing From The French Alps