Clickbank Redirect Script (PHP)

As always trying to use search engine marketing and optimization (SEM&O) in the best possible way, I try to combine them so they both workout perfectly.

Without delaying, here is the script that will create redirects for ClickBank (if you notice errors or want improvement, you can drop a comment):
<?php

// ClickBank Redirect/Cloak Script (PHP)

// example, relative URL: cb.php?s=STORE-ID

// made at http://shockmarketer.com

$nickname = 'multiz'; //your ID/nickname is at clickbank

$store = $_REQUEST['s'];

$extra = $_REQUEST['x'];


$tid = $_REQUEST['tid'];


if($tid)

{

$extra .= '&tid='.$tid;

}

if($store)

{

header('Location: http://'.$nickname.'.'.$store.'.hop.clickbank.net/?'.$extra);

}

else

{

//if something is entered wrong, they're sent to your not found (404) page


// or whatever page you choose.


header('Location: 404.shtml');


}


?>

For those of you who do not like reading useless instructions, a link would look like this:
<a href="/cb.php?s=store" rel="nofollow" title="Add an SEO friendly persuasion to the reader/buyer">Store</a>

How to use the script

1. Save the script as cb.php or something else and upload it

2. Change the line: $nickname = 'multiz'; to $nickname = 'YourClickbankNickname';

3. Link to merchant or store using their Clickbank ID (usually found as the subdomain after your Nickname; http://yourNickname.storeID.hop.clickbank.net)

4. Link like this cb.php?s=STORE-ID (although obvious, make sure you change STORE-ID; you have no idea how many people will mess this up)

Advanced parameters

1. You can add tracking IDs by linking like this: cb.php?s=STORE-ID&tid=TRACKING-ID

2. Add any extra parameters: cb.php?s=STORE-ID&x=MORE-Parameters

For more parameters, you will need to URL-encode any extra “=” or “&”.

Other tips (SEO & SEM)

1. Change robots.txt by adding Disallow: /cb.php to a new line

2. Add title attributes to links (can increase conversions and provide a little better SEO) <a href=”/cb.php?s=store” title=”A store that adds insane discounts daily”>Store</a>

3. Keep your pagerank by adding rel=”nofollow” to links <a href="/cb.php?s=store" rel="nofollow" title="A store that adds insane discounts daily">Store</a>

FYI: This should be able to prevent sneaky Adware that tries to place their ClickBank ID in your ClickBank links.

Share this:

Comments

20 responses to “Clickbank Redirect Script (PHP)”

  1. Terry Jett Avatar

    Excellent!

    Thank you for sharing this. Been looking for something simple.

    Terry

  2. daniel Nicholas Avatar
    daniel Nicholas

    Hi,

    I have a small bakery and I am trying to set up a simple affiliate program for a product I make which is a teething biscuit for babies. I am not a programer can you help me out?
    Thanks
    Daniel

  3. Mike Avatar
    Mike

    @Daniel: I’ll email you.

  4. Rifkin Avatar

    Dear Mike, Do you have live demo for that? I’d like to know…

    Rgds
    Rifkin

  5. Mike Avatar
    Mike

    @Rifkin: Well, no. It is just a simple PHP redirect configured to work smoothly for all of the ClickBank merchants.

    However, I do include example URLs, above.

  6. corner Avatar

    I think your code should modify as this:

    $URL=’http://’.$nickname.’.’.$store.’.hop.clickbank.net/?’.$extra;

    And the “header” function not always work,may be you can use meta reflesh instead.

    Thank you for sharing ๐Ÿ™‚

  7. Shadal Avatar

    This would be a great script, exactly what I’m looking for, if it would work ;-/

    I keep receiving this error:
    Parse error: syntax error, unexpected ‘=’…

    From line:
    $extra .= โ€˜&tid=โ€™.$tid;

    Any Suggestions?

  8. Mike Avatar
    Mike

    @Shadal: I think the problem is that the single quotes are not being displayed correctly.

    If you have any other problems as well, try replacing all of the single quotes with double quotes.

  9. Shadal Avatar

    Thank you!

    Replacing all of the ‘ with ” throughout the script worked!

    Excellent job, thank you for making this free!

  10. Shadal Avatar

    Ooops,
    I guess I spoke too soon. I wasn’t getting the error anymore and instantly thought it was fixed ;p guess I should have tested further…

    Every link I create directs me to:
    http://www.buyersgoingcrazy.com/?hop=xxxx

    I did go back through the script and again change all of the ” back to ‘ which now seem to parse just fine, but wrong website…

  11. Mike Avatar
    Mike

    Make sure you pass a store ID.

  12. Shadal Avatar

    Yep, I did that…
    http://shadal.com/article.php?s=energy4gre
    …takes me to the above site ;-/

  13. Mike Avatar
    Mike

    @Shadal: I think I see the problem… go down to the line like this:
    header('Location: http://'.$nickname.'.'.$store.'.hop.clickbank.net/?'.$extra);

    …and make sure the “$” is in front of “store”.

  14. Knight mayor Avatar

    Come on dude, these facts* and proof* i mean who is posting* lol ๐Ÿ˜›

  15. Ciprian Avatar

    Don t work look at this:

    http://commentsportal.com/niw.php?s=wesleya

    goes to this:

    http://www.thegidietbreakthrough.com/?hop=nectarius

    so conclusion is that still doesn’t work!

  16. Jesse T Avatar

    This php script is genius! It’s very simplistic and gets the job done!

  17. David D Ochoa Avatar

    This script has at least 1 flaw. Based on lines 21 and 29, there is an un-needed ampersand. (&tid=)

  18. Interview Questions Avatar

    That is a nice script. Sorry, I don’t have technical knowledge. But can this script be modified to have support for tracking IDs? Look great overall.

  19. Interview Questions Avatar

    Man, this code works & its very simple. Thanks for posting this.

  20. roland alexis Avatar

    make it work for me and send me an email when it is ready

Leave a Reply

Your email address will not be published. Required fields are marked *