AffiliCloak : Affiliate Link Cloaker
Version 1.2 - 1/7/2006
© 2005-6, Gecko Tribe, LLC
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
Where to find more information
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
Configuration
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.)
- 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.
- 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 "http://example.com/"
and you want your affiliate links to begin with "http://example.com/go/",
set $prefix to "/go/", like this:
$prefix='/go/';
Be sure to include the final slash character.
- 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 Amazon.com affiliate and your id is "example-01", change the Amazon.com line to this:
'a'=>'example-01', // Amazon.com
- 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 Amazon.com is 'a',
for AllPosters.com 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
- Upload affilicloak.php to the directory where your 404 error document is (or will be) located.
- 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
$prefixlen=strlen($prefix='YOUR_PREFIX');
if (substr($_SERVER['REQUEST_URI'],0,$prefixlen)==$prefix) {
include dirname(__file__)."/affilicloak.php";
exit;
}
?>
- 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.
- 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):
http://example.com/YOUR_PREFIX/PROGRAM_CODE/PRODUCT_CODE
For example, an Amazon.com affiliate link to the book "Affiliate Selling: Building Revenue on the Web" might look like this:
http://example.com/go/a/0471381861
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:
- 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.
- Upload the (possibly renamed) file to your webserver, preferably just inside your website directory.
- 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):
http://example.com/FILENAME.PHP?PROGRAM_CODE/PRODUCT_CODE
For example, an Amazon.com affiliate link to the book "Affiliate Selling: Building Revenue on the Web" might look like this:
http://example.com/go.php?a/0471381861
Note: On some servers, you can replace the question mark with a slash, for example:
http://example.com/go.php/a/0471381861
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.
- AllPosters.com
- Program code: 'ap'
- Product code: the name of the ".htm" file from the AllPosters affiliate link.
- Amazon.com
- Program code: 'a'
- Product code: the string of letters and digits that appears after "ASIN/" in the URL of the product page on Amazon.com.
- ClickBank
- Program code: 'c'
- Product code: the code that appears in the ClickBank hop link URL.
- Commission Junction
- Program code: 'cj' for the affiliate link, and 'cjimg' for the tracking image URL
- Product code: the "Link ID" or "AID" (depending on where on Commission Junction you're looking).
This is the last number in the links that Commission Junction generates for you.
- Notes: Because Commission Junction gives you a different ID number for each website that you have registered with them,
setup for Commission Junction is slightly different than for other affiliate programs.
Rather than entering your affiliate ID in the $ids configuration array,
you'll need to create entries in the $cjids configuration array.
For each website, create a line with the domain name and your PID for that website.
Be sure to enter the domain name in all lowercase letters.
If your website is accessible both with "www." on the beginning and without,
for example, "http://www.example.com" and "http://example.com",
you'll need a separate line for each,
even if you don't have a different PID for each (just enter the same PID on both lines).
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):
http://example.com/YOUR_PREFIX/TRACKING_SEGMENTS/SEG_1/SEG_2/PROGRAM_CODE/PRODUCT_CODE
http://example.com/FILENAME.PHP?TRACKING_SEGMENTS/SEG_1/SEG_2/PROGRAM_CODE/PRODUCT_CODE
For example, the Amazon.com link shown above might be changed to look like this:
http://example.com/go/2/review/1/a/0471381861
http://example.com/go.php?2/review/1/a/0471381861
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"):
http://example.com/go/1/recommended/a/0471381861
http://example.com/go.php?1/recommended/a/0471381861
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.)
Thank you for using AffiliCloak!