Home arrow ASP arrow Page 10 - Make Revenue With Your Own Banner Management System
ASP

Make Revenue With Your Own Banner Management System


In this article Mitchell shows us how to develop a simple ad campaign and management system using ASP and an SQL Server database.

Author Info:
By: Mitchell Harper
Rating: 5 stars5 stars5 stars5 stars5 stars / 33
November 01, 2001
TABLE OF CONTENTS:
  1. · Make Revenue With Your Own Banner Management System
  2. · Adding the banners
  3. · Saving the banners
  4. · The ASP to add the banner
  5. · The ASP to add the banner (contd)
  6. · Listing the banners
  7. · Deleting a banner
  8. · Displaying and tracking banners, impressions and click-thrus
  9. · The code in detail
  10. · Handling the banner clicks
  11. · Conclusion

print this article
SEARCH DEVARTICLES

Make Revenue With Your Own Banner Management System - Handling the banner clicks
(Page 10 of 11 )

Now, for the last - and easiest - step of our project, tracking the click-thrus. A click-thru occurs when a visitor clicks on any of the advertisements displayed on your site. When the visitor clicks the advertisements link, the click-thru count for that banner is updated, and then the visitor is re-directed to the page that contains the information/products relevant to that advertisement.

Remember how our GetBanner() function didn't link the banner directly to its URL, and linked it to bannerclick.asp instead? Well, bannerclick.asp acts as the intermediate page between our site and the advertiser's site, updating the click-thru rate for that banner and then re-directing the user to the site of the advertiser, as mentioned above.

Without further ado, lets create a new page called bannerclick.asp and save it in the same directory as bannercode.asp. Now type this code into your bannerclick.asp file:

<%@ Language="VBScript" %>

<!-- METADATA Type="TypeLib" File="c:\program files\common

files\system\ado\msado15.dll" -->

<%

dim objConn

dim objRS

dim strBannerURL

set objConn = Server.CreateObject("ADODB.Connection")

set objRS = Server.CreateObject("ADODB.Recordset")



objConn.Open "Provider=SQLOLEDB; Data Source=localhost; Initial

Catalog=myAdStuff; UId=sa; Pwd="

objRS.ActiveConnection = objConn

objRS.LockType = adLockReadOnly

objRS.CursorType = adUseForwardOnly



objRS.Open "select bannerURL from banners where bannerId=" &

Request.QueryString("bannerId")

if objRS.EOF then

Response.Write "Invalid banner id"

Response.End

end if



strBannerURL = objRS("bannerURL")

objRS.Close

objConn.Execute "UPDATE banners SET bannerClickThrus =

bannerClickThrus + 1 WHERE bannerId = " &

Request.QueryString("bannerId")

objConn.Close



set objConn = nothing

set objRS = nothing

Response.Redirect(strBannerURL)

%>


There shouldn't be much new code here. I'll just run through a couple of lines, the ones that matter.

objRS.Open "select bannerURL from banners where bannerId=" &

Request.QueryString("bannerId")

if objRS.EOF then

Response.Write "Invalid banner id"

Response.End

end if

strBannerURL = objRS("bannerURL")


This part of our code opens our recordset object, and selects only the bannerURL field from the record whose id matches the Request.QueryString("bannerId") variable (which comes from the link off the banner). If a record with this id doesn't exist, then we write "Invalid banner id" to the browser and simply end the page. If it does exist, we assign the value of the bannerURL field to the strBannerURL variable.

objConn.Execute "UPDATE banners SET bannerClickThrus =

bannerClickThrus + 1 WHERE bannerId = " &

Request.QueryString("bannerId")


If we skip a couple of lines down, we use our connection object to increase the number of click-thrus for this banner by one, again using the Request.QueryString("bannerId") as the id of the banner to update.

Response.Redirect(strBannerURL)

Last but not least, we re-direct the visitor to the actual URL behind the banner, and presto, it's all done.
blog comments powered by Disqus
ASP ARTICLES

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials