[home] [PDF Version]
If you often talk about about products on your weblog, then you might want to provide a link to amazon so that your readers can purchase the products you talk about. But what if your readers are from all the the world? People from the UK use amazon.co.uk and people in france use amazon.fr. Using a javascript application, you offer links to multiple sites at once, in a way that's tranparent for your readers.
To start, you'll want to grab a copy of amazon_lib.js and amazon_choose.htm which you can get from http://code.iamcal.com/js/amazon_lib/.
Before linking the javascript to your pages, you'll need to configure the site you'd like to link to. Open up amazon_lib.js in a text editor, and find the lines that start with AmazonAddSite:
AmazonAddSite('uk', 'Amazon.co.uk', 'http://www.amazon.co.uk/exec/obidos/ASIN/#ASIN#/myreferrername'); AmazonAddSite('us', 'Amazon.com', 'http://www.amazon.com/exec/obidos/ASIN/#ASIN#/myreferrername');
You'll need one line for each site you want to link to. The first part of the line is the label for the site which you'll use - in the example uk is the label for amazon.co.uk and us is the label for amazon.com. These labels are only seen by you, so can be whatever you like.
The second part of the line give the label that users will see on the site. This should be the actual name of the site that part three points to.
The third part of each line is the URL to a product page on the site, with one special exception - Where the product id would go (amazon call it an ASIN), you put "#ASIN#" instead. The javascript will later replace this with the id of the product to view.
In the example lines, a referal account name is included on the end, so that any sales genreated through the link earn you money. To learn dore about amazon's referral scheme, see: http://associates.amazon.com/exec/panama/associates/ntg/browse/-/567864/
Now that you've got the javascript configured, it's time to link it into your pages. You can do it by adding this line into the <head>l section of your pages:
<script language="Javascript" src="amazon_lib.js">></script>
Now you're all set to start adding links. For each link, you need to specify one or more site labels, along with the product id for that site. For instance, if i wanted to link to "Fight Club" on DVD, i'd find that the amazon.co.uk ASIN code was B00004W4HA and the amazon.com ASIN code was B000067J1H. Using this information, you can make the following link:
<a href="Javascript:Amazon('uk','B00004W4HA','us','B000067J1H');">link</a>
You can add as many pairs of label and product id as you like, so long as the label is defined in your javascript file, as detailed above.
Now, when a user click on a link for the first time, a popup appears containing the amazon_choose.htm document (you can customise the style as you wish). The popup asks the user to choose a prefered site from the list of sites your entered in the configuration.
Once the user has chosen a site, it stores their choice in a cookie (so it remembers their choices in future) and takes them to the relevant site. When they click a link again in the future, they are automatically taken to their preferred site.
If you'd like your users to be able