Practical Banner Rotation
By Al Williams
Many Web sites derive some, if not all, of their income from rotating banners. Such income can be monetary, or banners can pay off with reciprocating banner exposures on other Web sites. Banners can rotate any kind of content so that site visitors always see new information.
Several CGI programs are available to rotate ads. But why not use a form of script that's often simpler to manage than CGI? There are a variety of ways you can use client- or server-side script to rotate content. In the simplest case, a random number can select one of several chunks of HTML to display. However, this is only satisfactory for small sites. Larger sites with lots of traffic need more complex scripts to track click-through rates, and perhaps even target ads depending on the current page or other criteria.
I'll show you a few scripts that you can use as a starting point for developing your own rotating-content scripts. I'll start with a very simple example that's nearly universal, but has limited features. Then I'll move on to some more sophisticated applications.
The Basic Model
One way to get simple content rotation is to use JavaScript in the browser. This has several advantages. First, it doesn't require a special type of server because the script is embedded in the HTML and runs in the browser. This can lessen the load on your server. Unfortunately, browsers without JavaScript support won't be able to show your banners. There is a workaround for this, as I'll show you, that allows noncompliant browsers to show a static banner instead of a rotating one.<>