I use my webserver’s logs to count visits to my website.
The software “Webalizer 2” displays these data in plain form with some diagrams.
But now I want to count visits by a special group of users separately. I have premium users and standard users. For premium users I want to have a separate statistics page so that I can see how many premium users’ hits there are.
How can I achieve that?
In my PHP script files, I detect the status as follows:
<?php
if ($_SESSION['status'] == 'premium') {
// do something here
}
?>
The easiest way would – of course – be to have a MySQL update statement there to increment the premium users’ counter.
But that would also be a lot of database traffic. So I would prefer another solution.
I thought I could show a 1×1 pixels .gif image to the premium users. Then I could check the webserver’s statistics for the file “counter.gif”. BUT: I guess the client will cache the graphics file so my results won’t be correct, right?
Do you have an idea how to implement such a counter?
There are many solutions to this problem…
If you use a 1×1 pixel gif and are worried about caching, do something like this:
But then you’d still have to have some tool on the backend to track, and then analyze this data.
Alternatively Google Analytics has created simple ways to do this. Assuming you’re already using their tracking code, you can add a Custom Variable. See more here:
http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html#visitorLevel