Link to home
Start Free TrialLog in
Avatar of jeffreytp
jeffreytp

asked on

HTTP_REFERER

I want to log the Request.ServerVariables("HTTP_REFERER") when the 1st time a user enters any page on my root domain.  They could enter the site from say a search engine and land on page 2 of my site.  Then they may go to page 3 from there.  When the user land on page 2 I want to log the other dmain address they came from.  How do I do this?
Avatar of WMIF
WMIF

you can do this a couple ways.  it depends on your server and if you have access to a file called global.asa.  if you dont have access, its real easy to just track this with a session variable.  make a file that you would include on all of your pages.  this will check for a session variable and record your referer value if that session variable doesnt exist.  if it does, just go back to the first page.

include file:
<%
if not session("gotrefer") = "true" then
  'log http_referer
end if
%>

all other files:
<!--#include file="aboveinclude.asp"-->
<%
'other asp code...
oops, forgot one line:


include file:
<%
if not session("gotrefer") = "true" then
  'log http_referer
  session("gotrefer") = "true"
end if
%>

all other files:
<!--#include file="aboveinclude.asp"-->
<%
'other asp code...
Avatar of jeffreytp

ASKER

Thank you for your input WMIF  I played around with the asp code you provided and this is the code that does what I intended it to do, maybe you didn't quite understand what I was saying:

if not session("referer") > "" then
  'log http_referer
  session("referer") = Request.ServerVariables("HTTP_REFERER")
end if
that will definately store the referer information into a session variable, but i figured that you wanted to store this information into a database or file of somesort.  that is what i intended to replace the comment "log http_referer".  sorry i did not explain that better.  do you only want to store this into a session variable?
for now, and then I can take the session and place that into a DB.
ASKER CERTIFIED SOLUTION
Avatar of WMIF
WMIF

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just a heads up "Request.ServerVariables("HTTP_REFERER")" is not reliable as most antivirus packages like NORTON block it from showing up