AffiliCloak : Affiliate Link Cloaker
Version 1.3 - 6/21/2008
© 2005-8, Gecko Tribe, LLC

Free download
Where to find more information
Alternatives to AffiliCloak
Installing AffiliCloak
Supported affiliate programs and codes
Alternative link format for click tracking
If you don't have a web host yet

Thank you for choosing AffiliCloak! This document will help you get it installed and running on your website. If you have any questions, don't hesitate to contact me (link below). NOTE: AffiliCloak is a PHP script, and will only work on servers that support PHP.

- Antone Roundy   
Free download
AffiliCloak is freeware. Click here to sign up for your copy.
Where to find more information
AffiliCloak Homepage
Contact Me
Alternatives to AffiliCloak
I haven't actually used the following programs, so I don't have any specific recommendations, but I thought you might want to see what some of your other options are. These are (of course) affiliate links, protected by AffiliCloak:
Installing AffiliCloak
To configure AffiliCloak, edit the "CONFIGURATION" section in affilicloak.php using a text editor like Notepad. (If you use a word processor, be sure to save the file as "plain text". If doing so adds ".txt" to the filename, just change the filename back once you're finished.)
  1. Choose an installation method (two methods are described below). If your website can be configured to display a particular document when someone requests a page that doesn't exist (often called a 404 error page, not found page, "missing" document, etc.), or if it is already configured to use a PHP document for that purpose and you are able to edit it, I recommend using the first method. Otherwise, use the second method, which is easier, but results in less attractive link URLs.
  2. If you are going to use the easier (second) method, skip this step. Otherwise, choose a prefix to have appear at the beginning of all of your cloaked affiliate links (preferably a directory name which doesn't exist on your server). For example, if your website URL is "" and you want your affiliate links to begin with "", set $prefix to "/go/", like this: $prefix='/go/'; Be sure to include the final slash character.

  3. Enter your affiliate IDs in $ids for each program for which you are an affiliate. (Note: If you are a Commission Junction affiliate, configuration for that program is slightly different. See the supported affiliate programs and codes section below for details.) For example, if you are an affiliate and your id is "example-01", change the line to this: 'a'=>'example-01', //
  4. If you are an affiliate for any programs not already listed and are comfortable messing with the PHP code a little, you may add them to AffiliCloak as follows:
    • Add a line to $ids by choosing a unique identifier for that affiliate program (the identifier for is 'a', for is 'ap', etc.--just don't duplicate an existing id). The identifier must not begin with a digit and must not contain the slash character ("/"). I recommend choosing an identifier that begins with something other than a letter (for example, a minus sign) to avoid conflicts with future versions of AffiliCloak.
    • Add a line to the "switch" statement farther down the file by duplicating one of the existing lines and then editing the URL so that it matches the affiliate link URL with "$id" where your affiliate ID should appear, and "$prod" where the product code should appear.

Preferred installation method
  1. Upload affilicloak.php to the directory where your 404 error document is (or will be) located.
  2. If your server is already configured to use a PHP script for your 404 error document, add this code (with YOUR_PREFIX changed to whatever you set $prefix to during configuration) to the very beginning of the file (put it before any spaces, line breaks, etc.--NOTHING can appear before this code): <?php
    if (substr($_SERVER['REQUEST_URI'],0,$prefixlen)==$prefix) {
       include dirname(__file__)."/affilicloak.php";
  3. Otherwise (if you don't already have a PHP script set up as your 404 error document), create one (let's call it "missing.php") with the contents listed in the previous step followed by whatever message (including HTML code) you would like displayed when someone tries to access a non-affiliate link that doesn't exist, and configure your server to use it as your 404 error document.
  4. Create affiliate links like this, with YOUR_PREFIX replaced by the prefix you selected earlier, PROGRAM_CODE replaced by the unique identifier for the affiliate program, and PRODUCT_CODE replaced by the product code (see supported affiliate programs and codes for details): For example, an affiliate link to the book "Affiliate Selling: Building Revenue on the Web" might look like this: NOTE: You do not need to create a "go" directory, nor an "a" directory, and if you do, it must not contain a file named (in the case of this example) "0471381861". If such a file exists in that location, it will be displayed and AffiliCloak will not be executed.

Easier installation method with less attractive affiliate link URLs:
  1. Optionally change the filename of affilicloak.php to something of your choosing to reduce the probability of the filename "affilicloak.php" being recognized by affiliate link hijackers. Just make sure that the filename ends with ".php"--for example, "go.php", "link.php", "forward.php", etc.
  2. Upload the (possibly renamed) file to your webserver, preferably just inside your website directory.
  3. Create affiliate links like this, with FILENAME.PHP replaced by the filename you selected, PROGRAM_CODE replaced by the unique identifier for the affiliate program, and PRODUCT_CODE replaced by the product code (see supported affiliate programs and codes for details): For example, an affiliate link to the book "Affiliate Selling: Building Revenue on the Web" might look like this: Note: On some servers, you can replace the question mark with a slash, for example:

Adding extra text to your links:
Unless otherwise noted in the next section, you may add anything you wish to the end of your links. For example, instead of one of these: your link might look like one of these:
Supported affiliate programs and codes
The following affiliate programs are supported by AffiliCloak. As outlined in the configuration section above, AffiliCloak can be easily updated to support more affiliate programs than those listed below.
Alternative link format for click tracking
Beginning with version 1.1, AffiliClick supports a slightly modified link format containing tracking information. You can insert different tracking codes into the links on different pages, in different emails, or even in different parts of a single webpage or email, yet have AffiliClick redirect all of them to the same affiliate link. By analyzing your server logs, you can see how often your readers are clicking each of the links.

To use this format, modify your links from the format described above as follows (two versions of each example are shown, one for each of the installation methods outlined above): For example, the link shown above might be changed to look like this: The red number that is inserted immediately after your prefix or script filename is the number of tracking code segments to follow. In the example above, there are two, shown in green: "review" and "1". The segments must be separated by a slash character ("/"), as if each was the name of a directory.

You might use the link format in this example for the first link in a review of the book. If you have another link to the book further down the review page, you might change the "1" to a "2" to indicate the second link in the review. A link to the same book from another page (eg. a recommended reading list) might look like this ("1" tracking segment to follow, which contains the value "recommended"): Another use of tracking codes is for split testing different versions of your ad copy, headlines, etc. Using a different tracking code in the links in each version will enable you to determine which results in the most clicks.

The tracking codes need not be words or numbers as shown in these examples--they can be any characters which can appear in a URL.
If you don't have a web host yet
If you are looking for a web host White Hat Crew recommends iPowerWeb. They are a top-notch provider offering full-featured web and email hosting with excellent prices. I personally selected iPowerWeb for another business of which I am a part owner, and I continue to recommend them without reservation. (That is an affiliate link, so if you don't trust recommendations by affiliates, be sure to look over their information thoroughly before deciding whether to use them.)

Enjoy using AffiliCloak!