Floodle

There's fluff in my noodle

Friday, September 26, 2008

Horse Pizza - Context relevant Amazon Recommended Product Links

So you have a blog, and you want to display relevant Amazon ads on it, but you want them to relate to the post, not just to the blog in general.
When you create Amazon product banner ads, you enter keywords relevant to your content to make the products relevant to your readers. The problem with this is the same products show on all pages and may not be relevant to an individual post.
So I had a thought of making an amazon banner ad display ads relevant to the page context instead of keywords that I told it. So the plan was to pull some content from the page and use that to dynamically generate the code to trigger the Amazon ads. In this example I used the page title.
The process
1. Capture the page title
2. Take a couple of keywords from it
3. Generate the Amazon ad code with the keywords injected into it (using simple string concatenation.
4. Generate the HTML in javascript.
Here's the finished script


<script type="text/javascript">
pagetitle=top.document.title;
splittitle=pagetitle.split(" ");
search_text=splittitle[0] + "%2C%20" + splittitle[1];
iframe_string='<iframe src="http://rcm.amazon.com/e/cm?t=floodle-20&o=1&p=14&l=st1&mode=books&search=' + search_text + '&fc1=000000<1=&lc1=3366FF&bg1=FFFFFF&f=ifr" marginwidth="0" marginheight="0" width="160" height="600" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>';
</script>
<script type="text/javascript">
document.write(iframe_string);
</script>


Here's the explanation.
Line 1. pagetitle=top.document.title;
Purpose. Get the page title and store it in a variable named pagetitle
Line 2. splittitle=pagetitle.split(" ");
Purpose. Split the title into an array of words separated by a space " "
Line 3. search_text=splittitle[0] + "%2C%20" + splittitle[1];
Purpose. search_text is the text we will inject into the ad code, in this case I'm only using the first 2 words from the title and separating them with a space "%2C%20"
The next part inside the iframe is simply the code generated from the Amazon website where I've removed the keywords and injected my generated keywords instead.
Go to https://affiliate-program.amazon.com and login, Choose Build links and select Recommended Product Links and generate a sample in the format you wish to use - enter a dummy keyword, this is what will be replaced dynamically.
Last Line: document.write(iframe_string);
Purpose. Creates the html dynamically.
Other sites this may be good for would be forum - change line 3 to include more words as required.
It's not a perfect context but It's a start, you could also change line 3 so that one keyword is always there, then the rest are pulled from the title.
e.g. To have the word pizza always there, plus 2 others, use
search_text="Pizza" + "%2C%20" + splittitle[0] + "%2C%20" + splittitle[1];

Click this link

http://floodle.blogspot.com/2008/09/horse-pizza-context-relevant-amazon.html

To see the post with it's title and Amazon ads about horses and pizzas

Sunday, September 07, 2008

Online todo.txt editor

I'm a big fan of the todo.txt file, I have used it for years for tracking everything - only recently did I realise how many others use this method.

I use it for everything, taking notes during phone calls, noting down things that I hear people say that may be useful, any thoughts or ideas I have - pretty much anything that I see and hear at work that may be interesting or relevant gets noted.
I'm then left with a searchable archive of everything, people's names, tasks, general information - people I spoke to and what we spoke about.

The only issue with it is that it lives on my work PC which isn't always accessible which is why I created a simple online todo.txt editor which you can download and use if you want from ...

http://www.garven.net/todo

You need a web site to host it on but it's a single file install.

Labels: , ,