Affliate Link Cloaking Tutorial

Status
Not open for further replies.

Kfleming

Fired as a Mod
Feb 6, 2007
241
0
0
Philadelphia, PA
Hey everyone, as you can see i'm new here.. i just joined today. I usually hang out in the WMR irc chat but a friend convinced me to give this a shot as well=) Anyway i thought i would just share a tutorial i just wrote on how to redirect and cloak links which includes how to build a php redirect script to mask all of your affiliate links. You can find the original source on my blog located here - A Complete Guide to Link Redirection and Cloaking » Kevin B Fleming - Internet Entrepreneur

A Complete Guide to Link Redirection and Cloaking



Link Redirection which is also sometimes referred to as link cloaking is very useful for many things, some completely legitimate, and others not so legitimate.. however to many people redirection can be confusing, not necessarily because it’s hard, usually because there are just so may different ways to do it.


This guide covers four different ways to redirect a page… using PHP, JavaScript, .htaccess, and a Meta Refresh tag. It will also explain which methods are search engine friendly, and the best way to cloak a link for affiliate marketing and PPC purposes.

1. PHP Redirect

Most people like using PHP, because there is a ton you can do with it, and its processed on the server before it reaches the users browser, resulting in a very quick and search engine friendly redirect.
PHP redirection is what I personally use, mainly because of its flexibility. As you can see by the sample code below, redirecting with PHP is extremely simple and really just consists of 3 elements - An opening PHP tag, a location you want the page to be redirected too, and a closing tag.
When someone trys to access the page that the code below is placed on, they will be automatically redirected to the URL specified in the code.

example2.gif


It’s important to remember to not have any text before this script or it won’t work. I would not recommend including an additional content besides the script above on the redirect page.

You can download the php file here.


2. Advanced PHP Link Cloaking

Above I mentioned how I like using the PHP method because of the flexibility. Well now I’m going to show you how to build a more advanced link redirect system that you can use with multiple links. This is a perfect solution for affiliate marketing and PPC links.


First you will need to create a new PHP file…in this case i named it link.php.
Then as you can see below you need to include this simple script in which each if statement is a different page you want to redirect. This method is widely used in affiliate marketing because you can mask all your affiliate links using this one file and your URLS will then look like this…http://www.yoursite.com/link.php?dating - which would redirect to the dating url.

example1.gif


You can download the php file here

3. JavaScript Redirects
A JavaScript redirect is very simple to do because it can be done with just one line of code, as seen below. I don’t think this really needs any further explanation.

Code:
<script type="text/javascript">document.location.href=’www.yoursite.com’</script>

4. .htacces Redirects

I could probably write a whole guide in itself on the different ways you can use .htaccess redirects, however below are 3 different things you can use .htaccess redirection for. Like PHP using a .htaccess redirect is great because there is no delay since your browser checks the .htaccess file before it even checks the destination of the url. This type of redirection will not work on windows servers, and ALWAYS upload .htaccess files in ascii mode or else you can mess up your server, YOU HAVE BEEN WARNED.
Basicly all you need to do is create a file named .htaccess using a text editor like notepad, include the specied code below and then upload the .htaccess to the particular folder on your server your webpage or site is in. This method is very search engine friendly.
Move a Single Page:
Code:
Redirect 301 /old.htm   http://www.yoursite.com/new.htm

Move a Site:
Code:
Redirect 301 / http://www.yoursite.com

Changed File Extention:
Code:
RedirectMatch 301 (.*)\.html$   http://www.yoursite.com$1.php

5. Meta Refresh URL Redirect

This is a very simple redirect that you include in the meta data of a page. Honestly I would not recommend using this type of redirect, using a PHP redirect is far more Search Engine friendly but regardless, some people still use this. All you need to do is copy and paste the code below into a pages META Data and replace the URL with the URL of the page the visitor should be redirected to. The number before the URL is the time (in seconds) you want the browser to wait before redirecting the visitor.

Code:
<meta http-equiv="refresh"   content="8;url=http://www.yoursite.com" />
 


I edited your post because...

1- It's not very good forum manners to have your first post going directly to your blog.

2- We don't allow threads directly promoting your blog, you have to post the entire article here, but can use the source link for references or links.
 
do you ever see that when you do redirects that you have a much lower epc? (the links might not be tracking right). I was using a 301 redirect for cloaking links and it definately wasnt tracking right for me. I switched to a php redirect and it seems alot better, but my epc is still higher on pages where i dont do a redirect. Maybe its just me. Good post though
 
As i said in the tutorial i HIGHLY recommend using the PHP redirect if your doing any type of affiliate marketing or PPC stuff. The browser never actually loads the original page, and thus its a lot faster and shouldn't give you any tracking problems. Plus with PHP you can easily build a redirect system to quickly setup redirects for 10 or even hundreds of links.
 
I'm a pretty big believe in the PHP redirect. I use it in my own subdomain url redirection service and I use it whenever doing my own promotion of affiliate offers and suggest it to my affiliates.
 
I like that PHP redirect, it seems like a safe and very good alternative to using any type of JS or meta refresh. Then again, you can always use those flash redirects that those asshole phishing kids were using on myspace. Sure they were using them for fucked up things, but the redirection code/file itself was fuckin awesome. See, sometimes you can get something good out of something bad.
 
Not to knock on KFleming, but here is a different setup which should be easier when you start adding a ton of redirects:

Code:
<?php

$path = array(
  'dating' => 'http://dating.com/index.php?id=myaffid'
  );

if (array_key_exists($_GET['id'], $path))
  header('Location: ' . $path[$_GET['id']]);

?>

When you want to add another redirect, all you do is add one line in a simple format:

Code:
$path = array(
  'dating' => 'http://dating.com/index.php?id=myaffid',
  'one-night-stand' => 'http://onenightstand.com/index.php?id=myaffid'
  );

Remember, there is a comma after each line except the last. This should be all you need to use to manage your redirects. You links will be

http://domain.tld/link.php?id=dating
http://domain.tld/link.php?id=one-night-stand
 
Hmmm, a PHP redirect does a 302? I've been using 301 redirects, and my conversions have sucked, maybe I'll switch to a 302 and see if that changes anything.
 
I am not really very knowledgable when it comes to scripting, but here is what I am using (PHP). You call it like http://domain.com/...links.php?a=1. How does this code compare to the one OP recommends?


<?
function check_search_engine() {
if ($a == 1) {
header("Location: http://afflink1.com");
exit;
}
IF(!isset($_SERVER['HTTP_USER_AGENT']))
{
$user_agent = '';
}
ELSE
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
}

$search_engines[] = 'Fast';
$search_engines[] = 'Slurp';
$search_engines[] = 'Ink';
$search_engines[] = 'Atomz';
$search_engines[] = 'Scooter';
$search_engines[] = 'Crawler';
$search_engines[] = 'bot';
$search_engines[] = 'Genius';
$search_engines[] = 'AbachoBOT';
$search_engines[] = 'AESOP_com_SpiderMan';
$search_engines[] = 'ia_archiver';
$search_engines[] = 'Googlebot';
$search_engines[] = 'UltraSeek';
$search_engines[] = 'Google';

foreach ($search_engines as $key => $value)
{
IF($user_agent != '')
{
if(strstr($user_agent, $value))
{
$is_search_engine = 1;
}
}
}

IF(isset($is_search_engine))
{
return TRUE;
}
else
{
return FALSE;
}
}
?>
<?
if (check_search_engine() == TRUE) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
</body>
</html>
<?
} else {
$a = $_REQUEST['a'];
if ($a == 1) {
header("Location: http://afflink1.com");
exit;
}
if ($a == 2) {
header("Location: http://afflink2.com");
exit;
}
}
?>
 
That takes it one step further, and actually cloaks the link (in the true sense of the word) so that search engines don't even follow the link, they just see an empty document. This *could* potentially get you in trouble with search engine terms of service though for PPC buys, and you sure wouldn't want to point adwords ppc traffic directly to that script. Should be fine for use on landing pages though.
 
I am using it for my aff links on the landing page. I did try sending one campaign straight on a separate account via that script, but it disabled the ads due to the destination domain not matching the display.

I bet that isn't going to to be good for that acc's QS.

Would it be safer to just use the other, simpler script?
 
I do a lot of redirection. And combo's of these things are what work the best. Example say you have 20,000 blogger blogs and all are different keywords and niches. To make like easy put the same js redirect on each blog. Have that redirect point to a php script on a server (also known as double redirection). The server check the url of the blog the traffic is coming from and then redirects it to the appropriate affiliate landing page. This way you can easily control traffic from a ton of sites with just the flip of a switch.Also, whats nice about this as well is you can put a geo-ip script on the server and a cloaking script in the server to feed engines something different should you want to.

Another step further out for that would be keep a js file and src= load it and have cloaking built in the js which works well on public hosts that don't support php directly.

On a whole different note 301 and 301 redirects can be useful on different engines for ranking purposes, but I'll let you figure that out. Meta Refreshes are pretty cool because they usually strip out the referrer where they other methods don't. Typically they're a little slower but if can be useful.

Hope this helps :)
 
I was using the basic affiliate script on clickbank and couldn't get it to work. I've used it on 3 other affiliate networks with no problems. Would any of these methods work?
 
SE's are pretty dumb when it comes to anything really. However if you're trying to get a whitehat site by on these cloaking/redirection ideas you're probably traveling down the wrong road. If you're going to do something whitehat, well do it whitehat. Last thing you'd want is to get a manual ban once you were ranking really well for stuff based on something shady and they will eventually catch you.

Now on the flip side of that if you're going to do something blackhat, do and do it all the way. My BH thoughts on js vs. cloaking are doesn't really matter. SE's algo's can't read either if done right. The idea people often miss behind blackhat is the strategy which is build MASSIVE amounts of whatever you're doing. In a typical day I build 2k sites.

Some rank, some don't.
Some get banned, some don't.
Some make money, some don't.
Some last a minute others last a year.

But who gives a shit what happens some will always rank, make money, and not get banned. It's the volume that matters not worrying what the SE's do to your site.

When I was doing a lot of selling my buddy I used to work with used say "Throw enough shit against the wall and some will stick some will fall!"
 
Good point, smaxor,lol

How does the redirection methods mentioned here compare with the framed redirection method here; Affiliate Link Cloaker - How the Affiliate Link Cloaker Works

Code:
</script>
<!-- !STOP! WARNING: you are not authorized to view this Code - Close your text editor immediately -->
<html><head>
<script>window.status = ' ';</script>
<meta http-equiv="Content-Language" content="en-us">
<title>[B]--TITLE--[/B]</title>
<meta name="keywords" content>
<meta name="description" content>
</head>
<frameset border="0" frameborder="0" marginleft="0" margintop="0" marginright="0" marginbottom="0" rows="100%,*">
<frame src=[B]--URL--[/B]" scrolling="auto" frameborder="no" border="0" noresize>
<frame topmargin="0" marginwidth="0" scrolling="no" marginheight="0" frameborder="no" border="0" noresize>
<noframes>
<body>
</body>
</noframes>
</frameset>
</html>
Is there a clear winner for affiliate/PPC?
 
A stupid tutorial.

How often is someone going to steal your commision? Um hum how about zero? What percentage of you visitors are even computer savvy enough to a. recognize an affiliate link, b. sign up for the same program as you, and c. change the code to get a commission

maybe instead of being paranoid about affiliate theft you promote better offers that convert. Just a thought.
 
Status
Not open for further replies.