Forum Moderators: DixonJones
When the page is requested I use microtime() to determine a start time. I also INSERT records to a table. Those records include the page name, referer, date and time, and I set a flag in the table to N.
At the bottom of the page, microtime() is used again and compared to the first value. This give me the page load time - one stat I'm watching closely on a few pages. The flag that was originally set to N is now UPDATE'd to a Y in the table, along with the page load time. This is my indication that the visitor did not click away before the page was fully loaded.
This is all done with PHP and MySQL database. Obviously, it's not perfect... I only get stats for pages with the code inserted. Some referals are blocked. But, for those pages I'm interested in watching, I have 'real-time' tracking stats available from my Admin panel.
I'm not really trying to re-invent the wheel with logging stats. I can see a few potential problems including large amounts of esentially duplicated data, and a slight hit on overall page performance. Besides these, are there any others I should be aware of?
Thanks
If you need to know exactly when a page has finished loading in the browser you need to use JavaScript and the "onLoad" event.
;)