Cloaking your affililate links is a recommended practice for anybody seriously involved in affiliate marketing. Not only will affiliate link cloaking help prevent people from stealing your commissions, it can also allow a secondary mechanism to track the links going out of your site without completely relying on the affiliate program’s internal tracking. Most affiliate networks permit url cloaking and ClickBank actually encourages it to prevent hi-jacking of affiliate commissions. While there are many ways to handle affiliate link cloaking, I personally have found that using a PHP file to redirect requests is the simplest yet most effective method to accomplish this task.
Here’s how I handle affililiate link cloaking…
Create a directory named “out” in the root of your website and create a file named “index.php” with the following code :
<?php
if ( empty( $_GET['at'] ) ){
// this is the default link if no destination is specified
$link = "http://YourClickbankID.DefaultProgramID.hop.clickbank.net/";
}else{
if ( $_GET['at'] == 'Program1' ){
$link = "http://YourClickbankID.Program-1-ID.hop.clickbank.net";
}elseif ( $_GET['at'] == "Program2" ){
$link = "http://YourClickbankID.Program-2-ID.hop.clickbank.net";
}
}
header(’Location: ‘ . $link ); ?> |
Note: If you have trouble copy and pasting the code above into your site, here’s a text file with the code in it.
As you can see from the example above, you will specify a default link in case there is no program specified and then you will specify two more links to whatever programs you are promoting. If you want, you can always add more program links by simply adding another “elseif” switch at the end of the second “if” statement. The “header” function causes the actual redirect to whatever url is specified in $link, so to call your cloaked link to Program1, all you have to do is write your url as follows :
http://www.mysite.com/out/?at=Program1
Which will send your visitor to :
http://YourClickbankID.Program-1-ID.hop.clickbank.net
This is the simplest method of cloaking a ClickBank affiliate link and it can be used to cloak any affiliate links whether it be PepperJam, NeverBlueAds, CJ or any CPA network that uses hop style links. You can see this script in action by clicking the Fat Rich Pig or Adwords Profits links on the sidebar of this blog.
As I stated in the beginning of this post, if you want to add additional tracking to your cloaked links, you can always create a MySQL database and populate it with data every time somebody clicks one of the cloaked links. Data you might store can be the page the link came from, the IP address of the person who clicked, the date and time of the click, the program the visitor clicked to and the affiliate network the click went to. This is especially useful if you have several sites or blogs and you’d like to track them all against the various affiliate networks you might be using. Note: To do this, you must add your code before the actual redirect happens in the “header” command.
For anybody interested in the advanced tracking script, please subscribe to my RSS feed via email and I will send you a copy free of charge. Please leave a comment on this post if you have any questions and I’ll try to help you out as best I can.
Until next time…
Happy Publishing,
Dave





















Url Posted at C4G Forum…
I saw some people asking this question on DP forums, so I wrote this postHop……
Instead of making a new elseif for each program to the list, you may populate the inputtet “at=” variable into the hoplink dinamically.
This way, a link to:
site.com/out/at=anything
will redirect to:
username.anything.hop.clickbank.net
And by “anything” I really mean anything, so you should also make sure to escape the string to avoid SQL injections.
Thanks for sharing this tip. I am doing a similar php redirect although I took it as an individual php file.
Too bad i didnt come across this blog before. Great stuff you got here. Thanks.
This is a wonderful post. I was astonished to learn that it’s so easy for someone to hijack your bare affiliate link and use it to earn your commissions. Thanks for the post
this is great stuff, I will start using this info right away. thanks
Great info for newbies who are starting out affiliate marketing without fearing their commissions being hijacked.
Dear Dave,
Thanks so much for the code for cloaking cb hops.
I have on one page 11 possible out links and would like to track all to try to analyse what goes on.
Do you have any code for doing this?
I’m a newbie but can set up an sql database using cpanel with instructions.
Any help will be greatly appreciated.
Kind Regards
and I will definitely be subscribing.
Brian
Dear Dave,
Tried the php cloaking script but geting ths error
Warning: Cannot modify header information - headers already sent by (output started at /home/newest/public_html/out/index.php:3) in /home/newest/public_html/out/index.php on line 24.
any ideas
Line 24 is:-
22) elseif ( $_GET[’at’] == “Program303″ ){$link = “http://t28022006.amdproduct.hop.clickbank.net/?tid=303/”;}
23) }
24) header(’Location: ‘.$link );
25)
26) ?>
Best Wishes
Brian
Brian,
You have a space or some other output appearing before the header redirect. That’s why you’re getting the error. For the “header” function to work properly, there must be no other output before that function is called otherwise the header will fail in the manner you’re showing.
Check your script and make sure nothing else is being outputted to the browser before you make the call to the header function.
You can PM me at C4G forums if you need help.
[…] you can simply create html or php redirects. Here’s a good one: How to Cloak Your ClickBank Affiliate Links __________________ PHP Link Cloaker: Hide Affiliate Links & Track Clicks. Secure, Web-Based, […]
I am sure this is GREAT information. It sounds very technical, and I don’t understand it exactly. I am trying so hard to learn ALL of these things I need to do so I can make some money and keep a roof over my head. MY UNEMPLOYMENT WILL BE ENDING IN A COUPLE OF WEEKS.I lost my job in the mortgage business Feb. 21, and my old Buick was stolen April 7. So it looks like the only hope I have is to get some money working on this GRANDFATHER computer.
I have a clickbank account, but no website, YET, and very little money. I thought IF I could just figure out how to cloak the hop link then I would do some marketing using classifieds and email, BUT I AM STILL LOST. IS THERE ANY HOPE FOR ME??
[…] cloak a Clickbank affiliate link? Refer to Free ClickBank Affiliate Link Cloaking: CBAE.net and How to Cloak Your ClickBank Affiliate Links __________________ Affiliate Marketing Community - Join […]
I tried doing a html redirect to cloak my link but with todays new secure browsers and advanced anti virus it’s hard to get past their security alerts. I had loads of emails sent to me telling me that my cloaked link was setting off anti virus alerts and also the new no script in Firefox actually shows your real link anyway.
How do we get around that?
Jonathan
@Jonathan Black - What you’re talking about is not necessarily a “cloaked link”. Redirects are an integral part of maintaining infastructure. Also, I do believe the customers of yours who have complained must have their security settings on default high security. We all know that if you spend hours in your browser, you figure out how to remove all those silly warning messages but newbie internet users will complain to you about something they should be complaining to Microsoft or Firefox about…
Anyway, you could just do a 301 permanent redirect like this…
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.new-url.com” );
This is an old post but it was the first post on Google so I have a question. I am an Article Marketer but I know that some directories don’t allow dynamic links with the characters “=” or “?”. So regarding the affiliate or hoplink for clickbank tracking links, is there any way to get around this? Someone told me to check out this Doiop.com but that is a URL shortener and most directories wont allow that either. I can do the regular hoplink fine since its just a regular link but when it comes to tracking, I would like to be ABLE to keep track of what is going on relating to my link. Help would be appreciated.
Thanks
What about the NoScript plugin for FireFox? As more people get tools like that, the simple php redirect method does not work. Alternatives?
Richard
is this really a solution because certainly with clickbank when you checkout - the affiliate id is there and it turns up in the address box. So whats the use or do i have it wrong? Ive lost over $1000 past few days in commission theft. It would help if Clickbank would just dam well hide the affiliate id at checkout and it IS possible to do. I wrte to them today complaining - not that it will do me much good but what the hell!
This is good stuff - covers the ‘cloaking’ of affiliate links. So how do I *track* the clicks? Any info appraciated!
H
Dave, how do you do it for an iframe?
Thanks,
Dan
@Dan … I think iframes are always a mistake for SEO …
[…] look longer and nastier than ever. So what’s the recommended way to cloak? I did find this link How to Cloak Your ClickBank Affiliate Links but have a couple tech questions about that method as well. Also, is the use of TinyURL or another […]