ASP
  Home arrow ASP arrow Page 10 - Make Revenue With Your Own Banner Manageme...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Make Revenue With Your Own Banner Management System
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2001-11-01

    Table of Contents:
  • Make Revenue With Your Own Banner Management System
  • Adding the banners
  • Saving the banners
  • The ASP to add the banner
  • The ASP to add the banner (contd)
  • Listing the banners
  • Deleting a banner
  • Displaying and tracking banners, impressions and click-thrus
  • The code in detail
  • Handling the banner clicks
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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.

    More ASP Articles
    More By Mitchell Harper


     

    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...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT