Digsy has asked for the wisdom of the Perl Monks concerning the following question:

I would like to know where users of my site are coming from ? Can I use http_referrer to do this ? Digsy PS an auto-email notification of when someone reponds to a message like this would be v.cool

Replies are listed 'Best First'.
Re: Capturing external reffering url ?
by turnstep (Parson) on Dec 15, 2000 at 21:40 UTC
    Yes, you can use HTTP_REFERER to do this. It's really the only way, except for asking the users directly. And it is very easily faked or blocked. Still, the majority of users know not how to do this, so you can probably grab a lot this way. Parsing your access logs would be the best way to grab this, of course. Finally, make sure that your server is actually *logging* this. It usually appears as the last field in the access_log for apache servers.
Re: Capturing external reffering url ?
by Caillte (Friar) on Dec 15, 2000 at 22:01 UTC

    *grins* A more perlish answer is to read $ENV{'HTTP_REFERER'} ;)

Re: Capturing external reffering url ?
by Fastolfe (Vicar) on Dec 16, 2000 at 06:27 UTC
    HTTP_REFERER obviously would only work with CGI scripts. If you're concerned about traffic to your web site in general (really a non-Perl issue), consider setting up your web server logs to log referrer information and analyze those instead. That would be far more efficient.
Re: Capturing external reffering url ?
by tune (Curate) on Dec 16, 2000 at 03:35 UTC
    and the CGI-ish way is:
    use CGI; $query = new CGI; $referer = $query->referer(); # or do something you want with $query->referer()

    -- tune