Re: Visitors Counter
by Trimbach (Curate) on Jan 27, 2001 at 21:23 UTC
|
The best (and most accurate) way to get to the information you want is to access the server logs directly. With log access you can track "user visits" as opposed to raw page hits by correlating visits with time and such. There are lots of freeware Perl log analyzers out there that will do this for you, but the trick is getting the log data in the first place.
Unfortunately not everyone has access to the logs. If that's your situation you can try a technique I've used before with some success. On your main page (or any page you want to count visits) put a <img src="counter.pl"> tag somewhere on the page. "Counter.pl", when called, adds a count to a file somewhere, and then sends back a 1 pixel invisible gif to the browser.
The cool thing about this is that you're making use of a browser's cache behavior to prevent the same visitor from making multiple log hits. Most browsers will cache the output of counter.pl and not re-call the script if someone hits the same page later. Cool, yes?
Of course, it's not perfect as you are depending on the browser to prevent multiple counts (and believe me, it's never a good idea to depend on a browser to do anything :-P) but it should be more accurate than simply counting raw hits like you started with.
Gary Blackburn
Trained Killer | [reply] [d/l] |
|
| [reply] |
Re: Visitors Counter
by tune (Curate) on Jan 28, 2001 at 00:32 UTC
|
Trimbach's tips are almost complete. I would add the cookie-method.
You send a cookie to every visitor's browser with a desired expiry date. 1 hour for example.
If the browser does not send the cookie when visiting your page, you set it up and count a visit.
That's simple :-)
--
tune | [reply] |
Re: Visitors Counter
by mt2k (Hermit) on Jan 28, 2001 at 03:04 UTC
|
The cookie idea is mostly good, but remember:
- Some people actually don't allow cookies to be set
- Some get *really* angry when useless cookies are thrown at them...
- You might have some obsessive-compulsive people who just *have* to delete their cookies every two minutes :)
| [reply] |
Re: Visitors Counter
by DiscoStu (Initiate) on Jan 29, 2001 at 20:37 UTC
|
Randal has some interesting thoughts on counters man. You should check out http://www.stonehenge.com/merlyn . Very helpful. I am a mercy analyzes in crimson.
I am a mercy analyzes in microns.
| [reply] [d/l] |
|
I'm not certain, but I don't think merlyn likes to be referred to using his real name, unless you happen to know him.
I remember seeing a message where he took someone to task for that. I can't find it now, but I'm sure it's in Super Search somewhere, if you're really curious.
It would be also nice if you would take the extra moment to include the hyperlink code when pointing to outside sites.
| [reply] |
|
I'm not offended in the slightest by people using my realnametm.
I do get a bit peeved when the second L sneaks in, so spell it right!
-- Randal L. Schwartz, Perl hacker
| [reply] |
|
Forgive me for what I am about to write, brothers and sisters.
This does strike me as a bit of a snotty response, IMHO.
Lots of people use merlyn's real name on this site, and I
bet he doesn't know all of em. (Most, probably, but never all :P).
It seemed just the other day people were waxing lyrical on how to never turn away
a valid contribution to the site, even if it is from a known Troll. Well,
(compared to DiscoStu's track-record), this seems like a pretty valid contribution
to the original thread. So what happens now, after he/she sees this reponse?
Flame On, methinks.
I am not advocating Trolling, but I felt I should comment on this node as it may turn out to cause more harm than good
(I am NOT saying it was intended to cause harm, but ZydecoSue did seem quite terse and loaded with meaning.
Ladies and Gentlemen, Boys and Girls, I give you, my two cents.
Azatoth a.k.a Captain Whiplash
Get YOUR PerlMonks Stagename here!
| [reply] |
|
|