| Let's start by
listing the stuff you will need in order to make this work |
|
|
| 1. An object
callled MSWC.AdRotator |
|
If you are
running IIS Ver4, it is not automatically included but is on the
IIS Server Resource Kit. The good news is that IIS5 includes it. |
| |
|
|
| 2. You will
need a database, and this can be either Access or SQL |
|
|
| |
|
|
| 3. You will
need to either set a DSN or map the server path. |
|
For the
purposes of our example we are assuming a DSN. Within the database (we
called it "ads") we created a table called ad_log that
contains two columns: Sponsor & Clickdate |
| |
|
|
| 4. You will
need Active Server Page Support. |
|
Comes built in
with IIS4 & 5 |
| |
|
|
| 5.
For our purposes we chose to use GIF images as they are smaller and
faster to load. |
|
We
picked 440x60 pixels as our default size for the banners. |
| |
|
|
| 6. Besides the
actual banners themselves we created two files: |
|
|
| adRotatorSched.txt |
|
This is the
file that the AdRotator is expecting to see |
| gotoSponsor.asp |
|
Here is where
we track each click. |
| To keep stuff
neat and organized we put these two files and the banner images in a
folder called ads |
|
|
| |
|
|
| 7. Here is
what the adRotatorSched.txt file contains: |
|
|
REDIRECT http://www.shopmacleodtrail.com/ads/goToSponsor.asp
BORDER 0
*
/ads/banner1.gif
http://www.chinook-computers.com
Banner ads cheap $50/month
3
/ads/banner2.gif
http://www.chinook-computers.com
Banner ads cheap $50/month
2
/ads/banner3.gif
http://www.chinook-computers.com
Banner ads cheap $50/month
2
/ads/banner4.gif
http://www.chinook-computers.com
Banner ads cheap $50/month
3
/ads/banner5.gif
http://www.calgaryhumane.ab.ca
We support the humane society
2
/ads/banner1.gif
http://www.chinook-computers.com
banner ads cheap
1 |
|
The
first line redirects the "clickee" to our tracking page.
Depending on your monitor size this may appear on two lines but it
should be coded as one line.
Next comes an optional border setting, followed by the all important
asterisk. The ad rotator next expects to see the path to whatever
banner file is to be presented. After this it expects to see the
hyperlink that will be followed. The next line is the text version. It
is important to not leave this out, as the object expects certain lines
in the correct order. The number that is all by itself following that
represents the number of times out of the total that the banner will
present itself. So in this example we have a total of 13
presentations and the first banner will appear 3 out of 13
times(randomly). |
| |
|
|
| 8. Here is
what the gotoSponsor.asp page contains: |
|
|
| <%@
LANGUAGE="VBSCRIPT" %>
<%
sponsorURL = Request.querystring("url")
'create the object
set adstDB = Server.CreateObject("ADODB.Connection")
'Open the connection
adsDB.Open "ads"
'Insert the record here
sqlText = "insert into ad_log (sponsor, clickDate) values
('"
sqlText =sqlText & sponsorURL
sqlText = sqlText & "','"
sqlText = sqlText & Now
sqlText = sqlText & "')"
adsDB.Execute(sqlText)
'Close the connection
adsDB.Close
'Destroy the connection
set adsDB = Nothing
Response.Redirect sponsorURL
%>
|
|
This bit of
script opens the database, inserts the URL that has been clicked
(hyperlink line from the AdRotatorSched.txt file), and also
inserts the current time and date. Don't forget to close the
connection and destroy the objects. Once this page has finished its job
of updating, it then redirects the clickee to the page they are supposed
to go to, which is contained in the variable sponsorUrl. |
| |
|
|
| 9. Last but
not least we have to present the banner on the page. This is done with a
code snippet that can be placed just about anywhere. Here it is: |
|
|
| <%
set AdvObject =
Server.CreateObject("MSWC.AdRotator")
adHTML = AdvObject.GetAdvertisement("/ads/AdRotatorSched.txt")
Response.Write adHTML
%>
|
| Note: The page
containing the code snippet above must have an asp extension for
example this page is aspscript.asp. |
|
|
| |
|
|
| Have a good time creating and
tracking banners. In the near future we will create a reporting
module that retrieves, sorts and totals the information that has been
saved into the "ads" database. |
|
We originally learned about this
method from Nicholas Chase's book, "Active Server Pages 3. from
scratch" |