Hide Affiliate Links with PHP

When marketers sign up for an affiliate program, you are provided with special affiliate tracking links to keep track of your referrals & manage your earnings.

Most affiliate programs equip affiliate marketers with the following type of tracking URLs:

Example: SEObook.com
Affiliate Link = http://www.seobook.com/2496.html

The subfolder contains unique tracking codes that send data back to SEObook’s database to monitor how much traffic you’re sending. You will always use this link to promote SEObook, but this is not the proper way to present links to your visitors.

Redirecting your visitors from a sub-directory with PHP is the safest and most efficient way to promote and earn commissions from your affiliate relationships.

Why You Should Hide/Cloak Affiliate Links

Masking affiliate links protects both the affiliate and website visitor for a number of reasons:

  1. Prevents search engine spiders from penalizing websites with complex affiliate links & traffic codes.
  2. Insures you receive credit for informing visitors of a helpful product or service. If you took the time to inform your visitors of a wonderful resource, then you deserve credit for the hat-tip.
  3. Maintains root domain consistency within your website, and safely guides visitors to external resources.
  4. Places all affiliate links under 1 easy to maintain sub-directory for future maintenance. Affiliate managers alter affiliate links all the time.

How to Create a Simple PHP Redirect

A simple PHP redirect will allow you to link to any product you’re promoting without revealing the URL source.

  1. Grab your affiliate code, and open up your FTP access to create a new subfolder under your domain.
  2. Choose a simple name for the folder like “recommends” or “reviews” or whatever. I personally use “r” currently to limit the length of the URLs.
  3. Create a PHP file called “productname.php” and enter the following code:
    <?php
    header (’location: AFFILIATE LINK GOES HERE’);
    ?>
  4. Save the folder, then upload it to your subdirectory.

Now when you want to send traffic to your affiliates, simply link to the PHP file you just created.

You could even create a MySQL database to track clicks, use a custom link cloaking program to handle everything for you, or code a custom PHP script for all your affiliate links. Your options as an affiliate are endless!

So How do you hide your affiliate links?

Related Articles

Comments

14 Responses to “Hide Affiliate Links with PHP”


  1. Juggler Says:

    Nice post, this is helpful especially to affiliate marketers. Keep it up! :D



  2. John Sadler Says:

    Thanks for a very useful tip. I have Power Link Generator but to date I cannot get the darn thing to work. In PLG it tells you it can be a problem using cloaking on your sales page but that is something I cannot help with.



  3. Affiliate Link Cloaker Review Says:

    [...] I used to create affiliate links with PHP by hand, I now pick a product, grab the link, and leave all the heavy lifting to Affiliate Link [...]



  4. Tarik Says:

    I’ve heard about the issues with PLG. I now use Affiliate Link Cloaker to create all my affiliate links.

    It’s simple and works like a charm.



  5. Ballac Says:

    Here is a simple suggestion to completly hide your affiliate links. Just visit http://cutelink.info and hide your affiliate links within 20 seconds. The tool is very simple to use.



  6. Ballac Says:

    Those are good suggestion, but complex for new web makers or bloggers. So for new members, Iam giving one suggestion: http://cutelink.info

    That site help you to hide your affiliate links completly. No need of using javascripts more.



  7. Honest Web Host Says:

    Found this site through Google Search. Thanks for your php code tip.



  8. Tarik Says:

    Thanks for the Link Ballac. This is similar to TinyURL.



  9. Tarik Says:

    No problem, Web Host.

    I’ll be including a few more PHP tutorials in the future. Most of them either related to Wordpress or are very easy to learn.

    Thanks for visiting!



  10. Jay Says:

    Thank you very much! I didn’t know it was this simple! You don’t know how much this simple tip has helped me. You are god! Thank you thank you thank you!



  11. David Says:

    Hi!

    I’ve created several php files with dreamweaver and also with notepad, including the php code, but none of them are working :(
    When I click on my link, it only shows me a blank page, but everything else seems to be correct, so I can’t imagine what the mistake could be. Any suggestion?



  12. Tarik Says:

    Hi David,

    Please copy and paste one of the files into the comment so I can take a look.

    You’re probably omitting an argument in the PHP code.

    Thanks!



  13. G.Parthiban Says:

    Very very helpfull to me as an affiliate marketer. This is very nice to improve my too long web site names. Fantastic job. Keep it up. Wishes to continue sucessfully.
    G.Parthiban



  14. Tarik Says:

    Hi G,

    Glad you enjoyed the post.


Leave a Reply