Welcome to Dream.In.Code
Become a PHP Expert!

Join 149,843 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,380 people online right now. Registration is fast and FREE... Join Now!




Track Time

 
Reply to this topicStart new topic

Track Time

dumbo
20 Feb, 2007 - 06:43 AM
Post #1

New D.I.C Head
*

Joined: 8 Feb, 2007
Posts: 4


My Contributions
I am searching for a way to track and send the amount of time a user spends on each web page. Any good ideas?

Thank you.
User is offlineProfile CardPM
+Quote Post

Spider
RE: Track Time
22 Feb, 2007 - 01:22 PM
Post #2

Arachnid
****

Joined: 10 Jul, 2002
Posts: 769


My Contributions
You can track people who use your site with cookies and some funky system where each time a user does something (i.e. loads a page) on your site you record in a database how long they've been there.

I can't think of a way of sending immediate data, but if you stored the info in a database you could certainly build up daily "time spent" stats.

They won't be terribly accurate though, since you can't grab cookie information unless someone loads a page, so if they opened up the browser, read something for half and hour then left, you wouldn't know...

There may be a better solution smile.gif

Edit: I might possibly have meant sessions, not cookies. You could achieve a similar thing with either though.

This post has been edited by Spider: 22 Feb, 2007 - 01:25 PM
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Track Time
22 Feb, 2007 - 01:33 PM
Post #3

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 15,267



Thanked: 61 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
If you are looking for this information just to track stats, I would suggest a free stats program like http://www.google.com/analytics, AwStats, Webalizer, or something similar.

If you are trying to track just 1 page, then yes, you'll have to use cookies or something to track how long.
User is online!Profile CardPM
+Quote Post

Craige
RE: Track Time
22 Feb, 2007 - 06:00 PM
Post #4

D.I.C Head
**

Joined: 2 Nov, 2006
Posts: 63


My Contributions
There is no way to get "accurate" stats without using Javascript and Ajax, which is highly not recommended. The most you can do is each time the user loads a page, update a "online_time" feild, which the user has, lets say 2 minutes, added on to their time count, unless it has been less than two minutes since they loaded the last page, in which case you add the appropriate amount of time.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:06AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month