Three Easy Ways To Cloak Affiliate URLs
This article began its existence as a support article for Master Series CGI program affiliates.
The article has been modified a bit to clarify that the cloaking methods can be used for any affiliate link structure that I am aware of. The original article, should you be curious or are considering becoming an affiliate, is at /a/26t/pl.pl?art264
Why Cloak?
Some people won't click on affiliate URLs, or they'll remove the affiliate code before clicking.
Some affiliates prefer that prospective customers don't know they are about to click on an affiliate URL.
Cloaking an affiliate URL is an effective way to deal with both of the above situations.
Affiliate URL Cloaking with HTML Redirect
This is a really easy redirection method. A META tag redirects the browser immediately after the page has loaded. This redirect method has been mentioned as a tip on many web sites.
This redirect, however, is speeded up with JavaScript. If the browser is JavaScript-enabled, the redirect kicks in *before* the page finishes loading. Even a fraction of a second can make a big difference to an impatient prospective customer.
First, make a web page with the following HTML code:
<html>
<head>
<meta http-equiv="refresh" content="0; url=URLGOESHERE">
<script type="text/javascript" language="JavaScript"><!--
window.location="URLGOESHERE";
//--></script>
</head>
<body>
</body>
</html>
Next, replace both instances of URLGOESHERE with your affiliate URL.
Decide on an appropriate file name for the web page ("master.htm" for example, or emulating the name of the program you're linking to, like "form.htm"). Once the file name has been decided, upload the web page to your server.
Now you can simply publish the URL of your web page instead of your affiliate link URL. The web page will redirect the prospective customer with your affiliate link.
Note that this can appear to disable the browser's "back" button. The "back" button needs to be clicked twice, in rapid succession (just a twitch slower than a double-click) in order to get back to the original page where the link was clicked.
One way to bypass what could be an annoyance is for the link to open a new window. This way, when the new window is closed, the previous window will be at the original web page.
Affiliate URL Cloaking with Ad/Link Click Counter Software
This method allows you to link directly to a script instead of to your affiliate URL.
Depending on the script you're using, it:
-
Counts the click and, if the information is available, makes a note of the referring URL.
-
Redirects the browser to your affiliate URL.
My favorite software in this category is ProLinkz(TM), a program I wrote and which is being distributed and supported by a third party. It not only tracks the number of clicks and referrers, it makes graphs with the numbers. ProLinkz can handle as many different ads and links as you wish to publish, tracking each individually or several as a group.
It would be a serious miss if I didn't demonstrate ProLinkz by using it for my own affiliate link to the program's description page. The affiliate link URL is /wmaf/p/pl.pl?plkz
You'll notice that the fact it's a ClickBank hoplink isn't recognizable until *after* the link is clicked and your browser redirected.
If you decide to buy and you don't want me to get a commission, use your own affiliate link. Unlike the Master Series CGI affiliate program, which locks in a referral cookie as soon as it's set, ClickBank allows the immediate overwrite of an affiliate cookie with another affiliate's link.
This is probably the easiest method of the three presented here. Once the program is installed, you simply use the control panel to assign link codes and view the results. The link itself is copy 'n paste.
Affiliate URL Cloaking with .htaccess Redirect
This method requires editing the .htaccess file in your document root directory.
Definitions:
- .htaccess file
-
This is a plain text file named ".htaccess" (note the leading period) that tells the server what to do under certain conditions. Edit with a plain text word processor like NotePad or BBEDit. You might or might not already have a .htaccess file on your server; use your FTP program to check. (Note that some servers are configured to hide the .htaccess file name from directory listings. To see if that's the case on your server, manually type in the file name and tell your FTP program to download it. If the file exists, it should download. If the file doesn't exist, the FTP program should provide a message to that effect.)
- document root directory
-
This is the directory in which your main/index page is located on your server. The main/index page would be the web page that is loaded by default if only your domain name is typed into a browser.
The page you're going to redirect doesn't have to exist. In fact, it shouldn't exist because nobody gets to see it anyway.
This is how it works:
A link is clicked to a certain web page on your server. The server, instead of fetching the web page and giving it to the browser, just redirects the browser to a new URL.
It's very fast.
First, make up a web page file name for each affiliate link URL you want to redirect. For example, master.htm and form.htm for the Master Series home page and the Master Form V3 description page.
Next, add a line to your .htaccess file for every redirect. Assuming the above two examples and assuming your Affiliate ID is "xx", these two lines would be added:
redirect 301 /master.htm /master/?xx
redirect 301 /form.htm /master/formV3/?xx
As you can see, each line has four parts, with a space between each part:
-
The word "redirect" is the first part. It tells the server what the line is for.
-
The number "301" is the second part. It tells the server what result code to give the browser.
-
The third part is a slash and the file name you've decided upon.
-
The last part is the URL where the browser shall be redirected to. (Remember to replace xx with your own Affiliate ID.)
Now, this is what happens (assuming your domain name is example.com):
You publish a link to http://example.com/master.htm
When it's clicked the browser is redirected to /master/?xx immediately after contacting your server.
Similarly, you publish http://example.com/form.htm and when it's clicked the browser is immediately redirected to /master/formV3/?xx
It's fast because no web page or script has to be loaded before the redirect can happen.
Those are three affiliate URL cloaking methods. There are others, but I think the above three may be the easiest of them all.
Will Bontrager
©2004 Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.