2010-04-24

Search Engine Optimization (SEO)

Here are some resources from Google to help you with Search Engine Optimization (SEO):

2010-04-05

Simple banner ad rotator using SSI

Here's a simple method to rotate multiple banner ads into one ad space on your webpage by using SSI (server-side-include) statements in your .html files on your linux server (note: does not work for .php files nor for Windows servers).

To keep things organized, create a directory in the root directory of your website and call it "/ads" (you can use any directory name or location you prefer; just make appropriate adjustments below).

For each banner ad that you want to show, create a text file for it and save it in the "/ads" directory. For example, you might have three ads: /ads/cookware.txt, /ads/cookbooks.txt, /ads/appliances.txt. Each file would have a bit of HTML code to show a banner ad; for example:

<a href="http://www.amazon.com/"><img src="amazon.gif"></a>

They should not contain <html> or <body> tags. They should just contain the basic HTML tags that are used to show the banner ad.

Create a text file named /ads/ads.txt that contains something like the following:

<!--#config timefmt="%S" -->
<!--#if expr="${DATE_LOCAL} <20" -->
   <!--#include virtual="/ads/cookware.txt"-->
<!--#elif expr="${DATE_LOCAL} <40" -->
   <!--#include virtual="/ads/cookbooks.txt"-->
<!--#else -->
   <!--#include virtual="/ads/appliances.txt"-->
<!--#endif -->

The %S (that's a capital letter S) says that the server should look at the seconds hand of the server's internal clock to determine what ad to show. Since the probability of a user visiting the website during any given second (of 60 seconds) is the same as any other second, on average, the ads will be shown evenly over a reasonable amount of time.

The #if with "<20" tests to see if the seconds is less than 20 and causes the first ad to be show. The #elif (means "else if") with "<40" tests to see if the seconds is less than 40 and causes the second ad to be show. The #else (i.e.: all previous tests failed) causes the last ad to be shown.

Why "<20" and "<40"? Because in this example, three ads are being rotated. Take 60 seconds and divide by 3 ads to get 20 seconds per ad.

If you want to show a different number of ads then adjust the tests. For example, for five ads, you would use something like the following code:

<!--#config timefmt="%S" -->
<!--#if expr="${DATE_LOCAL} <12" -->
   <!--#include virtual="/ads/ad1.txt"-->
<!--#elif expr="${DATE_LOCAL} <24" -->
   <!--#include virtual="/ads/ad2.txt"-->
<!--#elif expr="${DATE_LOCAL} <36" -->
   <!--#include virtual="/ads/ad3.txt"-->
<!--#elif expr="${DATE_LOCAL} <48" -->
   <!--#include virtual="/ads/ad4.txt"-->
<!--#else -->
   <!--#include virtual="/ads/ad5.txt"-->
<!--#endif -->

For different numbers of ads, here are the tests to use:

2 ads: <30
3 ads: <20, <40
4 ads: <15, <30, <45
5 ads: <12, <24, <36, <48
6 ads: <10, <20, <30, <40, <50
7 ads: <9, <17, <26, <34, <43, <51
8 ads: <8, <15, <23, <30, <38, <45, <53
9 ads: <7, <13, <20, <27, <33, <40, <47, <53
10 ads: <6, <12, <18, <24, <30, <36, <42, <48, <54

Integrating the ad rotator into your webpage is simple. Use an SSI include statement in your webpage where you want the ad rotator to display an ad:

<!--#include virtual="/ads/ads.txt" -->

This statement will cause the ad rotator code to be included into your webpage, and it will then display one of your ads based on the clock's seconds.

Note: You might need to include the following statement in your .htaccess file (located in your website's root directory) so that the server will process the SSI statements:

AddHandler server-parsed .html .txt

That's how to create a basic ad rotator using SSI. If you have multiple ad spaces on your webpage and you want a different ad rotator for each ad space, create a separate ad rotator for each one (e.g.: /ads/top.txt, /ads/left.txt, /ads/inline.txt).

If you need something more complex, then have a look at the free ad server software OpenX.