Forum Moderators: DixonJones

Message Too Old, No Replies

Building a tracking system

What are the pitfalls

         

grandpa

1:25 am on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I've implemented a home-brew tracking system for some of the pages on my site. What I'd like to know if if I have overlooked anything obvious - or not so obvious. Here are some details.

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

dcrombie

2:30 pm on Nov 1, 2004 (gmt 0)



I don't know that that method will give you an accurate 'load time' as the PHP component of the page will be processed _before_ it's sent to the browser.

If you need to know exactly when a page has finished loading in the browser you need to use JavaScript and the "onLoad" event.

;)

grandpa

5:02 pm on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yeah, thanks. I was thinking about that late last night and realized the same thing. What it actually tells me is the time it took the server to serve the page (I think).