Reputation: 1622
Like this question, I wish to keep track of the number of page views. However, unlike that question, I would like to use MySQL to store the data. How do you propose that I set up my table to efficiently sore the data related to that specific page?
I would also like to apply some "intelligence" to the page counter. How can I keep track of the unique pageviews (similar to SO) in addition to the overall pageviews? How should I modify the table from above to suit these changes?
Additionally, could I use this information to track advertisement "views"? If so, how? If not, then I'll gladly post that as another question.
Thanks.
Upvotes: 2
Views: 625
Reputation: 25165
This could be the structure of the table you would record every-single-hit.
id | date | ip | user-cookie | agent
And then for performance reasons you could have another table that would be updated by a cron-job.
id | unique-hits
How to define a unique user?
This is a bit of a grey area where your own levels of paranoia kick in. A unique user can be a registered user and that should count as really one hit per user. You can follow the flawed one ip / one user. You can mix and match IP's and user agent's to try and better debunk unique users. Time can also be put into the mix, say every IP after x days will count as a new user.
Do you have a digital fingeprint?
Flash version, and other odities may cause your browser to be "different" from all other browsers creating a more unique view of yourself. Hit the great https://panopticlick.eff.org/ for a preview of what you may look like to a server.
How does Google Analytics does it?
Aparenttly they go cookie all the way.
Upvotes: 1