Lesson 8 | Controlling advertisement rotation with the schedule file |
Objective | Create a schedule file to control the display and rotation of ads. |
Controlling Advertisement Rotation with Schedule File
The
schedule file[1] is the "command center" for the Advertisement Rotator component. The schedule file contains details concerning the ads, including:
- Size of the advertisement space
- Image files to use
- Percentage of time that each file should be displayed
The
schedule file is split into two sections:
- a global section that has global settings (such as the size of the banner image), and
- a section for individual banners that has the following format:
REDIRECT /scripts/adredirect.asp
WIDTH 400
HEIGHT 55
BORDER 1
*
http://sixties–bands/ads/sixtiesbands.gif
http://www.old–rock–stars.com/
Swap memories and memorabilia with other fans of
sixties bands.
20
http://www.wolfgang–a–mozart.com/ads/requiem.jpeg
–
Call for our tours of Salzburg, Mozart's home:
(800) 555–3245
20
http://lunar–explorer/ads/crescent.gif
http://lunar–explorer/package–tours/
Join us for a virtual tour of the moon.
80
In this sample, named schedule.txt, all the optional values are set in the first section, and the second section lists three URLs.
Notice that the second URL (http://www.wolfgang-a-mozart.com/) doesn't have a home page, a phone number is displayed in the alt text instead.
Setting up the Advertisement Rotator
In order to set up and begin using the Advertisement Rotator component, you need to:
- Write a redirection script to process banner clicks
- Create a schedule file (
schedule.txt
in the example below) that lists the ad information. (Don't forget to include the URL for the script you wrote in Step 1!)
- In an ASP file, create an Advertisement Rotator object and call its
getAdvertisement()
method to insert the HTML for the banner ad
The following example displays a different advertisement each time a user views the Web page:
<% adRotate = Server.CreateObject("MSWC.AdRotator") %>
<%= adRotate.GetAdvertisement("/ads/schedule.txt") %>
When the script is processed ASP runs the GetAdvertisement()
method, which then looks in the schedule file and gets the information for the next advertisement. The ad information is then turned into HTML for display on the page:
<A HREF="/scripts/adredir.asp?<http://www.old–rock–stars.com/">
<IMG SRC="http://sixties–bands/ads/sixtiesbands.gif"
ALT="Swap memories and memorabilia with other fans of sixties bands."
WIDTH=400 HEIGHT=55 BORDER=1></A>
Question: Where does the GetAdvertisement method look to find which advertisement to display next?
Answer: The schedule file.
[1]Schedule file: A file which holds instructions for the order and/or frequency that ads will appear in the Ad Rotator Component.