Easy Affiliate Redirects
Mon, 13 August, 2007 – 6:08 pm
Probably about half of us at least use subdomain forwarding or Tiny URLs to hold affiliate links. Some call it cloaking links, essentially to hide the true link from the browser so that they're not necessarily aware that it's an affiliate link. Personally I use subdomain forwarding as I can't remember the various affiliate links I use! They usually come in the form of http://www.domain.com/?ref=1249382 and considering this changes from site to site I'm sure you can see why we use an easy redirect instead.nnHowever, not all of the links are easy to set up. One place I often waste a good 5 minutes just sorting out a link to is Amazon. When I want to link to a product on Amazon then I need to find it on their website and then eithernn1. Copy the whole product link and paste it into the correct box in the link generator within their associates admin area.n2. Copy the ASIN number given on the product page, and paste it into my standard Amazon link, in the middle of the whole URL.nnAn Amazon affiliate link looks like thisnn
http://www.amazon.co.uk/exec/obidos/redirect?link_code=as2&path=ASIN/1569244138n&tag=webtekdesigns&camp=1634&creative=6738
nnThe part that changes for each product is the ASIN number at the end of the first link, so in this case it would be "1569244138". As you can see, it's not so straight forwarding setting up a simple redirect for this as the URL changes for each product. So instead what I've done is set up a simple PHP redirect. It works by giving the file the ASIN number through the URL ie.nn
filename.php?id=1569244138
nnAnd then in the file called filename.php I have a simple php redirect asnn<?phpn$asin_no = $_GET['id'];nheader ("Location:http://www.amazon.co.uk/exec/obidos/redirect?link_coden=as2&path=ASIN/".$asin_no."&tag=webtekdesigns&camp=1634&creative=6738");nexit;n?>nnThat's it, all the code you need. This will take the id variable from the URL and plant it into your Amazon link and redirect you to that link. Note, for this to work you'll need to get your own amazon link which will probably different on the tag variable (in my case it's 'webtekdesigns') at least, if not the camp and creative variables too. However hopefully you should get the idea of how this works. I've simply replaced the ASIN number in the above link with ".$asin_no." (including the double quotes).nnAlso for this to work the opening PHP tag must be at the very top of the file. If you put a space in above it then you will get an error saying 'Output already started'. This is because this code is actually changing the headers of the file. It's a bit like a modern day meta refresh but is done by PHP so it can't be stopped by the user. However, the main reason for this is that I can now simply link to /amazon.php?id=ASIN-Number which is far simpler to remember!


Spooky. My next blog post is about redirects as one of the affiliate links I linked to last week did not work. I'll link up when I write it tomorrow.
By gary on Mon, 13 August, 2007
I only set the file up on Saturday when linking to a photography book I'd bought and figured that stuff like this may be of use to others. Look forward to your post
By Sarah on Mon, 13 August, 2007
Looks like Amazon's US affiliate system is significantly different than their UK affiliate system. Here's your code above, but formatted for 'mercans.nn<?phpn$asin_no = preg_replace('/[^0-9]/', ", $_GET['id']);nheader ("Location:http://www.amazon.com/gp/redirect.html?ie=UTF8&linkCode=ur2&nlocation=http://www.amazon.com/gp/product/".$asin_no."&tag=webtekdesigns&camp=1634&ncreative=6738");nexit;n?>nnHope it formats correctly here.
By Brian on Tue, 18 September, 2007
Cheers for that Brian. I do have a US Amazon account but didn't think to look at that one! Still, hopefully that may be of use to someone
nnGary did post up about this along with a little piece of software/script for it which may be of interest to some. Unfortunately my trackbacks aren't showing else it would have been linked up properly. Still his post is at Why you should use redirect links
By Sarah on Tue, 18 September, 2007