
|
|
|
Rotate Through Several Keyword Banners on Your Site
Keyword banners provide some rotation as people
visit your site, but to do cross-promotion with several keywords
across categories, you'll have to script a rotation
solution
The Code
[Discuss (4) | Link to this hack] |
Imagine you run a site for photography
enthusiasts. There are several subject areas and product categories
that they may be interested in: books of photographs, magazines about
photography, and digital cameras. Setting a single recommended
product banner for books with photographs would be fine, but you may
want to expand your product recommendations into those other subject
areas to increase the chances that someone will find something
they're interested in.
With a bit of scripting, you can set up some keywords and product
areas, and randomly select them for each page visit.
Running the Hack
You can add this code to any ASP page, or make the code its own page
and reference it from another file. For example, you could add the
code to a file called amazon_banner.asp. Then,
from another ASP file, use the server-side include method:
<!--#include file="amazon_banner.asp"-->
This keeps the banners easier to maintain, especially if they appear
on several pages across your site. When you add or remove keywords,
you'll only have to do it once.
The CodeThe following code can be added
to any ASP page: <%
'Add Keywords separated by commas
strKeywords = "insert comma-separated list of keywords"
'Add Modes separated by commas
'Potential values: books, magazines, music, classical-music,
' vhs, dvd, toys, baby, videogames, electronics, software,
' tools, garden, kitchen, photo, wireless-phones
strModes = "insert comma-separated list of product modes"
'Turn lists into arrays
arKeywords = Split(strKeywords,",")
arModes = Split(strModes,",")
intTotalKeywords = UBound(arKeywords)
'Choose a random number
Randomize
intRndNumber = Int((intTotalKeywords + 1) * Rnd + 1) - 1
'Set variables to the chosen random point in the array
strKeyword = arKeywords(intRndNumber)
strMode = arModes(intRndNumber)
'Make sure the keyword string is URL-safe
strKeyword = Server.URLEncode(strKeyword)
%>
<iframe marginwidth="0" marginheight="0" width="468" height="60"
scrolling="no" frameborder="0"
src="http://rcm.amazon.com/e/cm?t=onfocus&l=st1&search=<%= strKeyword %>[RETURN]
&mode=<%= strMode %>&p=13&o=1&f=ifr">
<a href="http://www.amazon.com/exec/obidos/redirect-home/">
<img src="http://g-images.amazon.com/images/G/01/associates/books2000/[RETURN]
clock468x60a3.gif"
width="468" height="60" border="0" alt="Shop at Amazon.com">
</a>
</iframe>
It's important to set up the list of keywords and product modes
correctly (see the list in the form code of ). Extending the
photography site example, here's how some banners could be set up: 'Add Keywords separated by commas
strKeywords = "photographs,photography,photography,digital photography,[RETURN]
digital cameras"
'Add Modes separated by commas
strModes = "books,books,magazines,books,electronics"
Notice that the positions of the keywords and the modes match. Though
the second and third entries in the keyword string are both
photography, the second and third positions in the
modes string are different: books and
magazines. When the random entry selected is 3,
the banner will show magazines that match the keyword
photography; when it is 2, the banner will show
books that match the keyword photography. TIPIf you already have keywords in <meta> tags
for a given page on your site, you can use those as your keyword
string and add appropriate product categories.
Showing messages 1 through 2 of 2.
-
Perl Version
2005-02-10 09:26:33
akaabc
[View]
-
ASP, what about PHP, JSP, and other???
2003-09-21 10:58:40
anonymous2
[View]
|
Showing messages 1 through 2 of 2.
|
|
O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website:
| Customer Service:
| Book issues:
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
|
|
and then you may use it like
hope that I wrote it right =))