Gossamer Forum
Quote Reply
Amazon Global
I have been playing around with Amazon’s new affiliate program. I would like to have the category name or search term inserted into the banner code.
For the category name I want to use commas, spaces or “+” between words, or phrases. To make a long question short- can I modify the following global to use “%20” or “+” by substituting them in
$cat =~ s|/|, |g; ??

$cat =~ s|/|%20|g;
$cat =~ s|/|+|g;

I am basing it on the global that puts comma-space in the cat name-

Code:
sub {
my $vars = shift;
my $cat = $vars->{category_name};
$cat =~ s|/|, |g;
return $cat;
}

How about search terms? Is there a tag that I may use for this also? I am assuming there must be since Lsql has several plugins for banner programs.

Or am I making this harder than it should be?
Smile

Quote Reply
Re: [jgkiefer] Amazon Global In reply to
Change

$cat =~ s|/|, |g;

to:

$cat =~ s,/,+,g;



Last edited by:

PaulW: Nov 20, 2001, 4:46 AM
Quote Reply
Re: [PaulW] Amazon Global In reply to
Thanks!
Is there a tag I could use for search terms?
Quote Reply
Re: [jgkiefer] Amazon Global In reply to
Hi -

I've developed a global for the current Amazon affiliate program that I think might be useful... it combines functionality for not only Links categories, but search terms as well.

For anyone who is not familiar, Amazon has implemented a way of delivering dynamic links to best selling books for certain keywords. This is great news for webmasters in general and LinksSQL users in particular because it is a simple matter of dynamically generating this "keyword" and then calling the Amazon javascript to your page using their provided code. This allows you, the web site owner, to deliver links to the specific books (or music, videos, games, etc) that your visitors are most likely to buy... those that are relevant to the content they are requesting! This means you can generate more sales and more commissions!

A quick overview on my approach to this global...

First, my particular directory has a great many categories (200,000+), with some being five, six, or seven "layers" deep. So, I had to figure out a way to try and deliver keyword phrases that will work well with the Amazon search function over the widest range possible. If you expiriment some with the "build a link" feature at the Amazon affiliate area, you'll see that phrases with too many words do not work very well and return just a generic ad, rather than the desired keyword-specific book links.

This makes it difficult to simply pass the entire Category into the Amazon javascript code, as you will often get undesirable (generic) results.

The following Global will take your entire category name (for example, "Entertainment : Games : Card Games : Poker : Rules") and remove top level categories from the beginning until the string is no more than the pre-defined "maximum" characters. I have this set to a default of 25 characters. So, the example category would return an Amazon search string of "Card Games Poker Rules" (It will also truncate search terms similarly). You might ask, why not just pass in the specific category name? Consider this very example... if you pass in just "Rules", you will NOT get the specific results you are looking for (i.e. you want Poker rules, not just "rules")... Likewise, truncating at the end instead of the beginning would also be undesirable, as you would end up with, in this case, "Entertainment Games", which will return some results, but not specific enough to your visitor.

So first, create the following Global:

amazon_term =>

sub {
my $tags = shift; # available tags
my $string;
if($tags->{category_name_escaped}) {
$string = $tags->{category_name_escaped};
}
elsif($tags->{term}) {
$string = $tags->{term};
}

$string =~ s/%2F/ /g;

my $maxchars = 25; # this value may be modified for desired results
until(length($string) <= $maxchars) {
my @words = split(/\s/, $string);
shift(@words);
$string = join(" ", @words);
}
$string =~ s/ /\%20/g;
$string =~ s/\+/\%20/g;
return $string;
}


Then, in your templates, call the clobal like this:

<script src="http://rcm.amazon.com/e/cm?t=YOUR_AMAZON_AFFILIATE_NAME_HERE&<%if category_id or query%>l=st1&search=<%amazon_term%>&mode=books&p=14&o=1<%else%>p=14&o=1&l=bn1&browse=1000&mode=books<%endif%>" type="text/JavaScript"></script><noscript>
<MAP NAME="boxmap"><AREA SHAPE="RECT" COORDS="37, 588, 126, 600" HREF="http://rcm.amazon.com/e/cm/privacy-policy.html?o=1"><AREA COORDS="0,0,10000,10000" HREF="http://www.amazon.com/exec/obidos/redirect-home/YOUR_AMAZON_AFFILIATE_NAME_HERE"></MAP><img src="http://rcm-images.amazon.com/images/G/01/rcm/160x600.gif" width="160" height="600" border="0" usemap="#boxmap" alt="Shop at Amazon.com">
</noscript>


Note, this specific linking method is for books... the mode can be altered for different items. Also, this code is for a tall, skinny box with six books listed. You will need to select your preferred linking method and place the global call as above.

Another note, the <%else%> part above ensures that general bestsellers are returned on your LinksSQL home page (and other pages, like New/Cool/etc) where no "category_id" or "query" exist.

This global works well over a wide range of categories. It is not the "perfect" solution, as some categories will not give any results, and some will give strange results, but by and large, it is a good solution for a wide and/or deep category structure. If your directory has only a few categories, you may get better mileage from a slightly different approach. (Perhaps simply passing only the category name, or if that is not feasible, possibly adding a new column to your category table "amazon_term" and then assigning values by hand for each category and then use that value to pass through the Amazon javascript... Although this global should still work well for you.)

I hope the above is helpful. Any comments or feedback are welcomed.

Smile
--
Matt G
Quote Reply
Re: [Matt Glaspie] Amazon Global In reply to
You should add that to the resources section (or get Bruce to do it Wink)


Adrian
Quote Reply
Re: [Matt Glaspie] Amazon Global In reply to
Great!
Just what I had in mind! I will give it a try.
Thanks!!

Wink
Quote Reply
Re: [jgkiefer] Amazon Global In reply to
YW...
Let me know how it works out for you. Smile

--
Matt G
Quote Reply
Re: [jgkiefer] Amazon Global In reply to
What code and tag works with Gossamer Links 3.3.0?
http://www.hopeforyou.com

Quote Reply
Re: [HopeForYou] Amazon Global In reply to
Why not just try the latest global? Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates