I’ve been a member of Amazon’s Associate program for a number of years and have posted affiliate links to books discussed on this very blog. The program means that by putting my affiliate ID into any links to Amazon products, I receive a small referral fee.
I’ve always linked to Amazon.co.uk as that’s my local Amazon store, but of course that’s not necessarily true for my visitors – or yours…
To solve this problem, I’ve written some JavaScript which will convert any Amazon product links on your page into affiliated links to your visitor’s local Amazon store. So US visitors will get a .com link, whilst UK visitors will get a .co.uk link to the same product.
Download
Setup
Edit amazon.js to insert your regional Associate IDs into the array at the top, for example:
var arrAffiliates = {
'co.uk' : 'petewill-19',
'com' : 'petewill-20',
'de' : 'petewill05-21',
'fr' : 'petewill-21',
'ca' : 'petewill00-20',
'jp' : ''
}
If you do not have an ID for each country, you can just leave them blank, as above for .jp.
Upload and Embed
As well as linking to amazon.js you need to link to the Google JS API file (5 kb) or the script will not work. Insert the following code just before your </body> tag:
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="amazon.min.js"></script>
Upload your modified amazon.js file, and make sure the above link points to the right location.
Usage
That’s it. You’re done! You can now just link to any product on any Amazon site with a normal, unaffiliated link and your users will get one affiliated for their country.
Example
The script is running on this page, so hopefully this example should be affiliated specially for you!
Disclosure
If you do not insert your own affiliate IDs the script will use mine. Hopefully this will help fund my book addiction!