Andrew Angell
asked on
How to track where a buying customer came from..???
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("H TTP_REFERR ER") 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!
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!
ASKER
So this should work..??
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
Session("referringURL") = Request.ServerVariables("H TTP_REFERR ER")
End Sub
</SCRIPT>
Then I can use Session("referringURL") to populate the database? Am I on the right track here?
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
Session("referringURL") = Request.ServerVariables("H
End Sub
</SCRIPT>
Then I can use Session("referringURL") to populate the database? Am I on the right track here?
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.
http://www.w3schools.com/asp/asp_globalasa.asp
You're on the right track...but read about global.asa.
ASKER
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. ServerVari ables("HTT P_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 ("referrin gURL"))
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?
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"
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"
Response.Write(Application
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?
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that'll work. thanks!
Then store the session varaible.