Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

web statistics

by advait (Beadle)
on Mar 03, 2008 at 17:30 UTC ( #671679=perlquestion: print w/replies, xml ) Need Help??
advait has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I have made a small website and hosted it on a web server. Now my boss wants to see the statistics which could tell
1. number of people visiting the site till date.( Unique vistors and number of hits per day)
2. their IP address/location
p.s. I have very limited permissions on the web server.
I have no clue how do it.
Can you monks please suggest me something
Thank you in advance

Replies are listed 'Best First'.
Re: web statistics
by dsheroh (Prior) on Mar 03, 2008 at 17:41 UTC
    Google "webalizer". It's a widely-use reporting application which does exactly that, complete with both pretty graphs and lots of useful information. It can be run manually, but really should be set up to run daily from cron, and requires no special permissions beyond the ability to read the web server logs.
Re: web statistics
by ww (Archbishop) on Mar 03, 2008 at 17:58 UTC
    use cgi; $count=43274112; print $count . "\n"; $count = $count = $count + 103; print "ohmigod, I can hardly keep up. " . $count . "\n";

    Joke, of course.

    More seriously, scripted counters tend NOT to count visitors very well. For two simple cases, even if one assumes that every visitor enters at the default page, that vistor will be counted twice if s/he leaves and comes back and may (depending on the sophistication of the design of the counter program) be counted if s/he browses from the default page to a sub-page and back again.

    You could deal with some of this with cookies (but some users will reject them), and if you have "no clue how to do it" then even with the wealth of nodes here on cookies, you have a serious learning curve to climb. One can hope you will do so, and the Monks will undoubtedly be pleased to help. On asking for help and Perl Monks Approved HTML tags provide many hints on how to ask for that.

    And (but NOT as an alternative; rather, as a supplement) You may wish to look at some previous advice on a similar question, at Visitors Counter.

    On the other hand, most hosts will provide some sort of stats, often in a directory so named. Some of those will offer (pretty) graphic data: visitors, "unique" (not really) IPs, etc. If the object is merely to get a general idea (and give the boss something to look at), those should suffice.

Re: web statistics
by superfrink (Curate) on Mar 03, 2008 at 19:37 UTC
    Have a look at Google Analytics. You have to signup with them and then put some code on each of your web pages. This method can not go back in time to give you previous stats. On the plus side you don't need access to the server log files. It also has a bunch of features like a map indicating where traffic is coming from.

    Another option is to run a program on the web server log files. A couple you can use are webalizer or awstats. This method can go back as far as the log files go back. To use it you need to install some software (it doesn't need to be installed on the web server but you need the log files).
      I second the recommendation of AWStats, which I prefer over webalizer.

      It deserves mention that the stats available on the HTTP server are absolutely NOT accurate, and interpretation of them is very subjective. While these statistics packages can give you an indication of what's going on, it's a fuzzy indication at best. (Google Analytics is also quite fuzzy, so this caveat doesn't imply an endorsement of Google Analytics.)

        Define "absolutely NOT accurate". Barring server misconfiguration, disk/filesystem failure, or deliberate tampering with the logs, I don't see any way that the web server logs can be any less than absolute in their accuracy regarding which pages were served, at what time, and to which IP addresses.

        Referrers and user agents are the only things I can think of off the top of my head which go into my logs and are susceptible to spoofing by users1 and those shouldn't significantly affect the accuracy of log-based analysis.

        Absolutely agreed that it's all in the interpretation, though.

        1 OK, technically users could spoof their IP address as well, but that's a relatively sophisticated technique and they're not going to be able to see the returned page if they do it, so I'm comfortable with ignoring them for these purposes.

      Another option is to run a program on the web server log files.
      Have a look at Google Analytics
      If your visitor is like me, FF+NoScript are configured to deny Google Analytics (as well as * and others of their ilk). Your logs will give you a much better indication of your visitors without requiring the user to allow JS from other sites.
      My attitude on this is that if you want to track me as a visitor that is fine. If others wish to base their income model on something that does not benefit me, they have to stand in line. Therefore, if your site will not allow me to navigate without sending data to external (to your company) sites, you better have something I can't live without.
      Just my $0.01 (exchange rate is going to heck) ;-)
Re: web statistics
by Gavin (Chancellor) on Mar 04, 2008 at 12:56 UTC
    Further to what superfrink has suggested using Google Analytics you may find that these statistics are already available to you from your hosting service or are you hosting your web site on your own servers?

    Many hosting companies already offer this as part of their service.
    Giving all the information you require on their log files, page hits, IP address, date, time, duration of visit, which page accessed through etc.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://671679]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2018-01-23 01:21 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (238 votes). Check out past polls.