Published on: Sunday 20th June 1999 By: Ben Allen
Do you have an affiliate program for your website? Would you like to improve revenue by cycling which book is displayed depending on the day? The script below does just that, for the Amazon.co.uk affiliate program, although it can be used for the Amazon.com program with a few simple alterations.
Warning - This code will only work in Version 4 browsers!
Once finished, the code will look like this, with the book changing each day, on a repeating cycle:
The code for this can be seen below:
If you wish to use this script for an Amazon.com referral program, change the line:
document.write('<a href="http://www.amazon.co.uk/exec/obidos/ASIN/" + refno + ...
document.write('<A HREF="http://www.amazon.com/exec/obidos/ASIN/" + refno + ...
And change the message in the next line from " - Click here to buy from Amazon.co.uk" to whatever you want to appear.
Change the line affid = 'dynamicit', replacing dynamicit with your associate ID. If you fail to do this, people buying books will earn money for me, and not you! (Not that I mind).
Now comes the difficult bit - adding the books you wish to sell. First, save all the images of the books you wish to sell in the same directory as the HTML page. Save them as .gif files named from book1.gif up the the number of books you wish to sell, e.g. if you wished to sell 5 different books, you would save them as book1.gif, book2.gif, book3.gif, book4.gif, and book5.gif.
Now you need to enter the book details. These are entered between the tags:
// Book Details Start // Book Details End
In this case, the number in the line refno='0764502239'; refers to the book reference number. Replace this with the book's reference number that you wish to sell as the first book.
The next book, would have it's image saved as book2.gif, the code would be as follows:
case 2: refno='123456789'; bname='The Book\'s Title'; break;
You would continue to add each book in the format above, remembering to increase the number which appears after the word case. If, for example, you had 5 books to sell, the last book would be entered as follows:
case 5: refno='987654321'; bname='My last book'; break;
The last alteration to be made to the code is to tell the script how many books you are selling. You do this by altering the first line: mybooks = 4;.
Alter the number to the number of books you are selling to:
mybooks = 5;
if you were selling five books.