Page 1 of 1
Calculate time spent on web page
Posted: Thu Aug 13, 2009 4:22 am
by gauri
hi
i am trying to calculate time spent on webpage using php.
can anyone please help me???
Thanx in advance.
Re: Calculate time spent on web page
Posted: Thu Aug 13, 2009 4:55 am
by cpetercarter
Strictly, you cant do this in php. The server knows when a browser asks for a web page. It does not know how long the user looks at the page on the browser. You could write some JavaScript which would send a message to the server when the user navigates away from the web page. You would need a database table, or at least a flat file, to keep track of visitors. Or you could simply use one of the many free web-site tracking services which give you information about how long visitors stay on web pages.
Re: Calculate time spent on web page
Posted: Thu Aug 13, 2009 5:21 am
by robnet
Google analytics is a pretty fully featured tracking service (in JavaScript). You might not be able to easily deduce an individual visitor's information, but it does a good job of collecting and delivering general stats.
If you need individual user info that could be a whole new can of worms
