I’m currently in the process of developing a statistics module for my pages. I’m currently considering the following two techniques to enable page-specific statistics:
-
Querying the database directly upon request. This increases the time it takes to generate the page by about 100-200ms, which increases the overall time it takes to generate a page = bad.
-
Using a technique like tracking pixel. Inserting a 1×1 image at the bottom of my content, ensuring it gets loaded after all the content has been loaded. This doesn’t directly **affect page generation times.
<img src="tracking.php?pageID=391" width=1 height=1 />
I’m not stupid – I do realize that somewhere it will take the server 200ms to handle the information (gather, structure and insert), however, this shouldn’t affect the user.
One adventage I can see by using method one is that the statistics are updated BEFORE content is served, as opposed to method two – meaning that half-a-second visits counts too. Sometimes good, sometimes bad.
What’s the prefered way, preformance and smoothness wise to process statistics data? I’m open to other techniques aswell.
My perfered way: Awstats. It uses the apache log files to gather statics. But it really depends on what you want to gather.
Awstats will gather the number of requests, time of day, what brower, IP address. Anything that is in the apache logs. Best of all, it has zero impact on page loads and doesn’t require adding additional mark up to your pages.