Developing Feather-Weight Webservices with JavaScript

On target with WhiskerBiscuit

Dynamically Targeted Associate Ads

A whisker biscuit is an archery accessory to steady the arrow as it flies and ensure the shot will always be on target. It’s also a provocative piece of slang but there is no such thing as bad publicity and double entendre never killed anyone. Though doubtless a whisker biscuit has aided a murder or two.

There is a soup of generally ignored information in most web page requests. The referring page often has query information showing exactly what a user wants to see. The current page sometimes has the same. Even the title and content of a page give clues for targeting an advertisement.

Narrowing the target of a user’s interest is what marketing companies pay great green for.

When you mix this semantic discovery with another webservice like keyword driven Associates advertisements, you get a potent cocktail.

Who this is for

This service is for anyone who wants to place advertisements on a website. It is specifically for those who are Associates. You don’t need to be one to use it but you can’t make money otherwise. You could substitute the Associate ID of a charity of your choice—quite a few charities and non-profits are Associates—if you don’t want to have one yourself. If the service is used without providing an Associate ID, then an elektrum press’s ID is used.

If you wish to become an Associate, it’s easy. Visit Amazon’s Associate pages to learn about the program and sign up and get your own ID.

Targeting for Marketing

The goal posts

WhiskerBiscuit is a dynamic augmentation of an existing static service. It will be used to govern decisions about how to apply “Recommended Product Links” advertisements from Associates. These are not automated and must be built via their web form or by a web developer who can edit the HTML output from the form. We use this particular format, of the many provides because it can be keyword driven.

WhiskerBiscuit will use an augmented Query() object to narrow the best keyword choice; attempting to match the visitor’s declared interest as told by referring search queries, etc. Then it will write out the static advertisement with the dynamically discovered keywords.

It will allow the client code to set the size of the ad, the store/product-type to search in, and fall back keywords in case no sensible query information can be uncovered. Associates’s Recommended Product Links

They are straightforward HTML in an <iframe>. look like this; the src URI has been omitted for space.

<iframe src="..." marginwidth="0" marginheight="0" width="120"
height="150" border="2" frameborder="0" style="border:none;"

You can see that writing out the HTML for the <iframe> is simplistic. The height and width have to be variable to provide different sizes of ads.

This is what the src URI look like. o=1& p=6& l=st1& mode=music& search=Kyuss& fc1=000000& =1& lc1=0033FF& lt1=_blank& f=ifr& bg1=FFFFFF& f=ifr

Need to know

There are four keys in the src URI that we’ll need to touch, and the height and width in the HTML so we can deliver more than one ad format.


Your associate ID to be inserted into the ad1. The argument is not required but obviously recommended. If you omit it, the associate ID for an elektrum press will be used.
Required. The size of the ad. Allowed sizes are show below If size is omitted an error message in a <div> tag will be written out to the page.
Not required. Default is books; it’s the largest selection and generally works best. If you supply a non-existent store key, books will be substituted. See below for the list of possible stores.
Not required. override changes the priority of the keyword. If override is set, keyword will be used for the ad and the query, title, and referrer information will be ignored.
Not required. This is the seed for the ad generation. Things like “Internet,” “cats,” or “Java” are good candidates. Without override, the keyword is considered last.
If no meaningful terms are found in the document referrer or the current page’s query string, the keyword will be used to write the ad.

The possible values for the store parameter

vhs Associate ad sizes

The possible values for the size parameter, ads shown 1/3 scale offers a couple gargantuan sizes, like the completely goofy 468x336, which we won’t support because there is no good excuse for filling half the screen with an advertisement.

A sample call to WhiskerBiscuit.js

<script type="text/javascript"

The API/UI is locked down. Now for the service.

After Passing JavaScript arguments via the src attribute and Query catching for fun and profit, there is nothing difficult involved in writing out the HTML for the ad. Just apply the arguments and ta. The only new consideration is what part of the information is valuable for the search parameter keyword of the ad.

Where we find targeting information

The hierarchy of potential information

  1. A user override + keyword from the client script’s src arguments.
  2. The human semantic portion of the last page’s query string via the document.referer.
  3. The human semantic portion of the current page’s query string document.location.
  4. A user fall back from the client script’s src arguments.
  5. The <title> of the current page.

It’s possible, but atypical, that none of those will have any useful information. The client code doesn’t have to supply a keyword to fall back on, or an override to use it up front. There may be no referrer or no sensible information in it. There may be no query string in the current page. The page itself may be untitled.

This is great, what’s the catch?

There’s no margin in pangrams and greeking. The catch with the WhiskerBiscuit service is that it makes you money, so there is an automatic tip jar for an elektrum press in it.

The service will deliver the ad with your associate ID, if you have one and use it properly, approximately 98% of the time and an elektrum press’s the remaining 2%. If you do not include your own associate ID in the service call, the press’s will be used.


All the code in this manual except for WhiskerBiscuit is open for use and reuse. See Licenses and terms of use for more. The code for WhiskerBiscuit may not be altered or repurposed without written permission from an elektrum press.

1 A tiny percentage of ads served will use an elektrum press’s associate ID to override any other present. See above for more about it.
« Using JS code libraries, part 2 · WhiskerBiscuit in action »
Web Developing Featherweight Web Services with JavaScript
This is version 0.57b of this manual. It is a beta version with some gaps. We are grateful for feedback.

The code is the manual has not yet been fully tested against Internet Explorer. Bug reports are welcome.
An Elektrum Press Online