Baz has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: site statistics
by arturo (Vicar) on Sep 20, 2001 at 03:21 UTC | |
Warning: I have little to say of a practical nature here. I'll just try to explain why what you think you want to do is probably not the way you should try to do it. The URL of the referring page is not specifically a creature of the CGI protocol (it's defined by the HTTP protocol) the referrer is passed *to* the webserver by the client (the browser)1, so an uncooperative client needn't provide that information. The environment variable REFERER, which is available to CGI programs, is where to look. In Perl, that's in the %ENV hash, i.e. $ENV{REFERER} holds the value of this variable. The REFERER (yeah, that's how it's misspelled =) history isn't quite the same as the browser's history, either. Basically, the idea is that you have to follow a link, submit a form, or be redirected from a page to the current page for it to be the REFERER of the current page (so, e.g. if you type in a new URL, the page you were on when you typed that URL in will *not* be the referer of the new page; but it will be the previous one in your browser's history list, and it will be the one your browser attempts to display if you hit the "back" button). Otherwise, the value of REFERER is generally available to the server and (e.g.) can be included in the webserver's logs. You'll have to check with the admin of your webserver if you want that kind of information. There are log analysis tools that attempt to track the length of a client's "sessions" but they rely on a range of strategies, not just the referrers. I don't believe that even with browsers that implement Javascript, the history is *by default* available to you. And if it is (and it may well be, it's been a while since I checked this sort of thing), that's criminally bad design. Given all those caveats, if you *must* track user's progress ... and I'll assume you don't have nefarious purposes in mind -- is to do it from the server side. Set a cookie with a unique ID, and on each new request, add the URL of the request to the (ordered) list of things as the request is made. This will of course require that you have the ability to read the cookie on every request and modify your logs. This wouldn't be too hard to do in mod_perl, which allows you to define handlers for each phase of the Apache request cycle. That's pretty involved though. 1 From RFC 2068, which lays out the HTTP 1.1 Protocol :
HTH.
| [reply] [d/l] [select] |
|
Re: site statistics
by suaveant (Parson) on Sep 20, 2001 at 07:05 UTC | |
- Ant | [reply] |
by blakem (Monsignor) on Sep 20, 2001 at 11:23 UTC | |
I was quite pleased with the Analog logfile analyser. I was especially impressed with its ability to quickly churn through million line logfiles. Here are some sample stats linked to from the Analog main site. -Blake | [reply] |
|
Re: site statistics
by jryan (Vicar) on Sep 20, 2001 at 03:25 UTC | |
Well, the best way on getting site wide statistics is by using a weblog parser. A good one to try is awstats, which can provide some general stats on your website. It requires apache, but you should be using that anyways ;) If you are looking for an alternative solution, I have also written a weblog parser that has some additional functionality in some areas. It has your standard browser/os/hits/graphs/etc, plus a few unique features like a hierarchy view. It also requires apache. | [reply] |
|
Re: site statistics
by shotgunefx (Parson) on Sep 20, 2001 at 16:38 UTC | |
If by chance you don't have CGI available to you or you can't use the Apache modules, you could right a script that cookies the user and logs the page. You could call this script by inserting a 1x1 shim image onto each page. It's not the best solution but it works 99% of the time.
A lot of the sites we work on believe it or not do not have any CGI access for any users for security reasons. In these situations, we have to graft the functionality on in manners such as this.
| [reply] |
|
Re: site statistics
by Anonymous Monk on Sep 20, 2001 at 08:28 UTC | |
Edit by tye to change PRE to CODE tags | [reply] [d/l] |
by durrow (Initiate) on Sep 20, 2001 at 08:39 UTC | |
| [reply] [d/l] |