The Best Way To Count Visitors/Impressions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
allyhazell
Forum Newbie
Posts: 9
Joined: Mon Sep 13, 2004 12:43 pm

The Best Way To Count Visitors/Impressions

Post by allyhazell »

Hi,

I'm having a few issues with keeping track of visitors and page impressions on my website. No matter how much I search, I can't find the answer to my question.

Essentially I have two PHP counter scripts, one for visitors and one for impressions. These interact with our Mysql database. So no problems there. My question is how the visitor and impressions counter should work, to give the most accurate results.

Previously I simply had my counter page included in every page with an 'include' statement. It only did this if the User Agent (obtained using PHP) was not the Googlebot, MSN bot or Yahoo spider bot. The counter script then checked for a cookie, and worked out whether they were a unique visitor or an impression. This produced results, figures of around 50,000 visitors per day and 80,000 impressions per day. However, I read that the best way to do a counter is to include in in an <img> tag at the bottom of the page. So I did this. The figures have dropped by more than half since I did this.
I set up an extra db table to track and store all the people visiting the site, their ip, their user agent etc. I then added into the counter a query that set counted='y' in the database if it counted them as a unique visitor. That is when I started to notice that some of the people who were actually visitors to the site (came from a search engine search) were not being counted. I guess that those people may have the images switched off in their browsers, or may be using text browsers.

So my question really is, have I chosen the right way to count visitors and impressions, or should I choose another way? What methods to other people employ?

Thanks

Alastair
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I've never tried something like this - I've always used a third party service/script

We use Statcounter for work. Another option would be Mint which I've never tried, but seems pretty good.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: The Best Way To Count Visitors/Impressions

Post by Roja »

allyhazell wrote:So my question really is, have I chosen the right way to count visitors and impressions, or should I choose another way? What methods to other people employ?
The best answer to these questions I have ever seen is on the Analog page explaining "How the web works": http://www.analog.cx/docs/webworks.html .

Its not condescending - its actually rather technical, and does a great job explaining just what you can, and cannot accurately measure, and why.

Section 4 ("What you can't know") is the most helpful, in my opinion.
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Re: The Best Way To Count Visitors/Impressions

Post by Ree »

Roja wrote:The best answer to these questions I have ever seen is on the Analog page explaining "How the web works": http://www.analog.cx/docs/webworks.html.
That was a good reading, thanks.
allyhazell
Forum Newbie
Posts: 9
Joined: Mon Sep 13, 2004 12:43 pm

Thanks

Post by allyhazell »

Thanks for your help and tips folks, really helpful! :-)

Especially liked that article, made me feel a bit better about my struggle for stats.
Post Reply