Print Page | Close Window

Referral Script

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6460
Printed Date: 31 March 2026 at 11:59am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Referral Script
Posted By: spikeashlye
Subject: Referral Script
Date Posted: 16 October 2003 at 1:24am

Hey.

I searched the forum for referral script but didn't find what I was looking for.

I'm putting some banner ads on other websites and want to track who brings me the most referrals, nothing major just something basic. I just wanted to track the number of referrals are sent from each website. I am new to ASP and can't really get down what I need to do, I was thinking:

If I put my add on two websites:

http://www.sample1.com - http://www.sample1.com

http://www.sample2.com - http://www.sample2.com

I wanted to track which one brought me the most visitors something like...

<a href="http://www.mywebsite.com?ReferID=125"><img src="ss.gif"></a>

as a link, and then I could greate a database table with unique referid's. I would search the database for an existing referid, and then update there count (refer 125 = totalrefers + 1) or if the refer number didn't exist then just abort, or put in a generic field.

I think I could do the database part, but I'm just not sure how to read the referid. I can create the link back to my site which includes the referid like above, but I don't know how to read it, maybe I should direct them to a page like

<a href="http://www.mywebsite.com/refer.asp?ReferID=125"><img src="ss.gif"></a>

Somehow decode that raw string so I can read the refer id, then redirect them to my hope page... if all goes well the user will never see the refer.asp page, unless maybe a quick flick in the browser while they are being redirected.

Does someone know what I'm talking about? If so can you please help thanks.




Replies:
Posted By: FLATLINE
Date Posted: 16 October 2003 at 4:44am

Do something like this:

Dim ReferID
Dim sql
Dim rsRefer

ReferID = Request.Querystring("ReferID")
If ReferID <> "" Then
   sql = "SELECT totalrefers FROM tblRefers WHERE ReferID = " & ReferID & ";"
   Set rsRefer = Server.CreateObject("ADODB.Recordset")
   rsRefer.Open sql, ado
   If NOT rsRefer.EOF Then
      rsRefer("totalrefers") = rsRefer("totalrefers") + 1
   End If
   rsRefer.Close
   Set rsRefer = Nothing
End If

 

Just add that script to your homepage and of course modify it for your needs.



-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ


Posted By: spikeashlye
Date Posted: 16 October 2003 at 10:46am

That is really cool. You mean I only have to add that to my home page and don't need to have any special links? This way it will track everyone that refers to my website?

Whoa! Nice!

Just one more question, do I just put that anywhere, like in <% %> or do I need to put it in a special function so it knows when to execute? I'm not sure if that will execute every time the page is loaded.

THANKS!!!!!!!!!



Posted By: FLATLINE
Date Posted: 16 October 2003 at 6:28pm
It will be executed every time when the Querystring("ReferID") is not empty.

-------------
Visit my site: http://darkgreen.service-club.net - DarkGreen HQ



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net