How to Rotate 3 Ad Banners with Variable Frequency
If you have limited space on your website, but you want to display multiple banners, the easiest way to show your ads is to rotate the banners based on a random chance or a specific algorithm. With Wordpress plugins, you can rotate several banners with equal frequency, but there may be occasions when you want a certain banner displayed more often. Or, perhaps you would like to display some banners on certain days of the week. This guide will show you how to implent a three-banner rotation that is customized to suit your needs. It can be adapted for any number of banners.
Rotating Ad Codes With Variable Frequency
First, collect the urls/HTML codes for each of your three banners. Let's say the HTML codes are
Banner A
Banner B
Banner C
Suppose you want to display Banner A 45% of the time, Banner B 35% of the time, and Banner C 20% of the time. Open a blank plain text document, then copy and paste this code:
<script type="text/javascript" src="../..../rotban.js"></script>
Replace the ../..../ with the particular directory path that leads to your javascript file. And now you will have three banners rotating on your page with a customized frequency.
Rotating Banner Codes Based on Day of the Week
In javascript, you can make banner ads display on certain days only. For example, suppose you want to display Banner A on Sundays and Saturdays; Banner B on Mondays, Wednesdays, and Fridays; Banner C on Tuesdays and Thrusdays. Write these lines of code in your javascript file: The command getDay fetches the current day of the week. In javascript, the days are numbered Sunday = 0, Monday = 1, Tuesday = 2,...and Saturday = 6.Rotating Banner Codes With More Conditions
You can make banner ads rotate with a variable frequency that depends on the day of the week. This gives you the ultimate level of customization for ad banners displayed on your pages. For example, you can make Banner A and Banner B rotate evenly Monday through Friday. And on the weekends, you can make Banner A appear 30% of the time, while Banner C appears 70% of the time. Use these lines of code: When copying and pasting the code, remove any line breaks that occur within the document.write() command, otherwise the script will not run properly.You can even rotate the ads based on time of day, giving your website visitors the most relevant information according to when they are surfing the web. For example, people are more interested in advertisements for books, computer equipment and office supplies during the weekdays from 8am to 6pm. In the evenings and on weekends, visitors have other interests. Experiment to see which arrangements perform better, and thus maximize your revenue.
© Had2Know 2010
