ASP
  Home arrow ASP arrow Page 5 - Case Study: An Affiliate System With ASP
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

Case Study: An Affiliate System With ASP
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 3
    2002-06-17

    Table of Contents:
  • Case Study: An Affiliate System With ASP
  • Project Overview
  • The ASP code
  • The ShowLogin function
  • Generating links
  • Tracking Links
  • 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


    Case Study: An Affiliate System With ASP - Generating links


    (Page 5 of 7 )

    The ShowLinks function displays a HTML page that contains three things: a form to generate links based on individual product ID's, a form to generate links based on product categories, and a list of banners and links that the user can simply copy and paste directly into their HTML pages.

    The product links form
    The product links form allows the affiliates to enter the ID's of one or more products from the TechBuy website separated by commas. After that, they click on the "Build Links" button, which passes the ID's they entered to the CreateIDLinks ASP function.

    CreateIDLinks takes the comma-seperated product ID's from the form and builds a SELECT query around them. The product ID, brand, title and image are taken from the products table and are displayed along with an affiliate link to that particular product:

    txtProdIds = Request.Form("txtProdIds")
    arrProds = split(txtProdIds, ",")
    counter = 0

    for counter = 0 to UBound(arrProds)
    if IsNumeric(arrProds(counter)) then
    strQuery = strQuery & "prodId = " & arrProds(counter) & " OR "
    end if
    next

    'Get rid of the right at the end of the query
    if Right(strQuery, 3) = "OR " then
    strQuery = Left(strQuery, len(strQuery)-3)
    end if

    counter = 0

    if strQuery <> "" then

    strQuery = "SELECT DISTINCT prodId, brand+' '+prodTitle AS prod, image FROM Products WHERE " & strQuery & " AND Active = 1 ORDER BY prod ASC"

    if objRS.State = 1 then objRS.Close
    objRS.Open strQuery

    ...


    Each link has the tracking ID of the affiliate built into it. Here's a link for the AMD Athlon 2000+ XP, as shown above:

    <a target="_blank" href="http://www.techbuy.com.au/prodredir.asp?prodId=17783&at=27">Buy the AMD Athlon 2000+ XP 1.67GHz 266FSB (no fan) at TechBuy</a>

    We will be looking at how the inbound tracking works later, so we will leave it for now.

    The category links form
    The category links form works in much the same was as the product links form, however it build the links with tracking ID's to link directly back to one or more specific product categories.

    The category links <form> tag looks like this:

    <form name="frmAddCatLinks" action="affiliates.asp" method="post">
    <input type="hidden" name="where" value="gencatlinks">


    The hidden variable, where is used to tell affiliates.asp what to do when the form data is submitted to it. Haivng a value of gencatlinks makes the CreateCatLinks function execute.

    CreateCatLinks takes the one/more selected categories from the Request collection variable called txtCatIds and builds a SELECT query, like this:

    dim txtCatIds
    txtCatIds = Request.Form("txtCatIds")
    arrCats = split(txtCatIds, ",")

    for counter = 0 to uBound(arrCats)
    strQuery = strQuery & "catId = '" & trim(arrCats(counter)) & "' OR "
    next

    if right(strQuery, 3) = "OR " then
    strQuery = left(strQuery, len(strQuery)-3)
    end if

    objRS.Open "SELECT catId, catName FROM Categories WHERE " & strQuery & " ORDER BY catName ASC"


    The resultant recordset, objRS, now contains a list of category ID's and category names from the categories table. These are output as links in textboxes and each one contains the affiliates tracking ID:

    <textarea rows="3" cols="56" id="<%=counter%>"><a target="_blank" href="http://www.techbuy.com.au/category.asp?catId=<%=objRS.Fields(0).value%>&at=<%=intAffId%>">Buy <%=objRS.Fields(1).value%> at TechBuy</a></textarea>

    The links generated from the CreateCatLinks function look similar to those generated by the CreateIDLinks function:

    <a target="_blank" href="http://www.techbuy.com.au/category.asp?catId=CLEARANCESTOCK&at=27">Buy *Clearance Stock* at TechBuy</a>

    Pre-made Banners
    Lastly, we have the premade banners. These are simply static HTML links which bring the visitor into TechBuy's front page. Here's one of the banners links:

    <a target="_blank" href="http://www.techbuy.com.au/?at=27"><img alt="Click here to visit TechBuy" width="468" height="60" border="0" src="http://www.techbuy.com.au/tbaffban_1.gif"></a>

    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 4 hosted by Hostway
    Stay green...Green IT