Solved

How to track where a buying customer came from..???

Posted on 2006-06-16
7
354 Views
Last Modified: 2012-06-22
I've got a shopping cart setup that when a person completes an order it updates the database and sets the lead source in the invoice to Web Page (this is how my client has it setup.)  I'd like to be more specific with that and see where the person came from: eBay, BrokerBin, PriceGrabber, etc.  I know I can use Request.ServerVariables("HTTP_REFERRER") to grab a referring URL, but I'm confused as to where I put this and how I store it.

I was thinking I could store the referring URL in a session variable and then populate a field in the database with this along with the rest of the info that gets inserted. The problem is...how do I store this and make sure the correct URL gets inserted?  

If I store the URL in a session variable I'd have to add that to every page that the person could possibly enter the site with.  But then if they go to another page on my own site doesn't the referring URL now become the site itself?  So as soon as they load another page that sets the session it'll set to its own domain and overwrite the actual domain the person came from.

Am I missing something here?  How does one go about doing this?  Any information would be greatly appreciated.  Thanks!
0
Comment
Question by:Andrew Angell
  • 4
  • 3
7 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 16922484
Create the session variable in the global.asa in session_onstart.  It will only fire once per session when they come to the site.

Then store the session varaible.
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 16922721
So this should work..??

<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
    Session("referringURL") = Request.ServerVariables("HTTP_REFERRER")
End Sub
</SCRIPT>

Then I can use Session("referringURL") to populate the database?  Am I on the right track here?
0
 
LVL 31

Expert Comment

by:alorentz
ID: 16922798
global.asa  -  do you know what this file is?

http://www.w3schools.com/asp/asp_globalasa.asp

You're on the right track...but read about global.asa.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 11

Author Comment

by:Andrew Angell
ID: 16923426
Nope, never used it before.  I'm having a little trouble following along apparently.  Here's what I've done.  I created the following global.asa and put it in the root directory on my xp pro test machine.  All of the sites that I test on this machine are created in virtual directoies within the actual site root so that i can still keep them all seperate....I don't think this should be effecting anything should it..???

Anyway, here's the global.asa that I have:

<script language="vbscript" runat="server">

sub Application_OnStart
  'some code
end sub

sub Application_OnEnd
  'some code
end sub

Sub Session_OnStart
Application.Lock
Application("referringURL")=Request.ServerVariables("HTTP_REFERRER")
Application.UnLock
End Sub

sub Session_OnEnd
  'some code
end sub

</script>

I created the following test.asp page as well and put it in one of my sites' directories:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Application("referringURL") <> "" Then
      Response.Write(Application("referringURL"))
Else
      Response.Write("Nothing to show")
End If
%>

Loading that test page directly prints Nothing to Show, which makes sense to me.  So I then created a link from another test machine that linked to this test page, but when I view that I'm still getting Nothing to Show.

What am I doing wrong?
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 16923444
I've also tried putting the global.asa inside the virtual directory with no luck.  I read that a script will use it's closest global.asa file so I figured I'd give that a shot....again, no luck.
0
 
LVL 31

Accepted Solution

by:
alorentz earned 250 total points
ID: 16923834
You should not use application variables...only session variables.  And the global.asa shold be in the root directory.

But, let's make this simple.

Create a file called tracker.asp, and put this code in it:

<%
if session("referringURL") = "" then
   session("referringURL") = Request.ServerVariables("HTTP_REFERRER")
end if
%>


Then use tracker.asp as an include file (like <!--#include virtual="/tracker.asp" -->) and include it in all your pages (or only the pages you want).  That way it will track on any page of the site, and only record the referrer on the first page that is accessed.

That should work for you....
0
 
LVL 11

Author Comment

by:Andrew Angell
ID: 16924541
that'll work.  thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
API Location, separating out information 10 46
how to hide hopscotch tour popup page reload? 2 63
Using querystring in a hyperlink 3 46
Pass through dll 2 63
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now