Home arrow ASP arrow Page 5 - Case Study: An Affiliate System With ASP
ASP

Case Study: An Affiliate System With ASP


An affiliate system is essential for anyone selling products online. In this article Mitchell goes behind the scenes and shows us an affiliate system from one of his eCommerce web sites.

Author Info:
By: Mitchell Harper
Rating: 5 stars5 stars5 stars5 stars5 stars / 55
June 17, 2002
TABLE OF CONTENTS:
  1. · Case Study: An Affiliate System With ASP
  2. · Project Overview
  3. · The ASP code
  4. · The ShowLogin function
  5. · Generating links
  6. · Tracking Links
  7. · Conclusion

print this article
SEARCH DEVARTICLES

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