Calculate time spent on web page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gauri
Forum Newbie
Posts: 3
Joined: Thu Aug 13, 2009 4:19 am

Calculate time spent on web page

Post by gauri »

hi

i am trying to calculate time spent on webpage using php.
can anyone please help me???

Thanx in advance.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Calculate time spent on web page

Post 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.
robnet
Forum Commoner
Posts: 85
Joined: Mon Aug 10, 2009 8:32 am
Location: South East, UK

Re: Calculate time spent on web page

Post 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 :D
Post Reply