yoda69 Posted April 13, 2010 Share Posted April 13, 2010 Is there a way to measure how long a user spent on a page using php? Or better, is there a way to measure how long it took a user to confirm a form (click a submit button or a link) once the form element was loaded? Thanks Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted April 13, 2010 Share Posted April 13, 2010 There is no active connection between the server and the client with php. All you can do is Guesstimate - Set a timestamp for the current page the user requested, once the user changes/;requests a new page, reset the timer. Though once the user leaves the last page would be a long time so the last page is the most inaccurate. Even though you cant really tell how long someone is looking at a page (which is more releveant than being on a page and not looking). Basically you can get estimatesd but never a relevant exact accurate number. -CB- Quote Link to comment Share on other sites More sharing options...
yoda69 Posted April 13, 2010 Author Share Posted April 13, 2010 Okay, I guess then that the only way of doing what I want is using javascript? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 Yeah, but it's not really reliable to use JavaScript. There are many things the user can do that will mess with data. Such as closing the window. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted April 13, 2010 Share Posted April 13, 2010 And as i said, unless you have some extremely sophisticated webcam recognition software that could magically tell between different people, you just cant do it accurately. You will only get a guide, and the easiest guide is an average of time spent on all your pages. By tall ying up the times between page requests. -CB- Quote Link to comment Share on other sites More sharing options...
aeroswat Posted April 13, 2010 Share Posted April 13, 2010 You could save the current time on the form page and then save the time when submitted and compare the two? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 You could save the current time on the form page and then save the time when submitted and compare the two? And what if someone navigates away from the page and then return a few days later? Quote Link to comment Share on other sites More sharing options...
aeroswat Posted April 13, 2010 Share Posted April 13, 2010 You could save the current time on the form page and then save the time when submitted and compare the two? And what if someone navigates away from the page and then return a few days later? Well his actual question was to see when a submit button was pressed after the page had been loaded. So a timestamp easily takes care of this problem with no issues. 1) Page loads 2) Timestamp is set 3) User clicks submit button 4) Submission code executes + 2nd timestamp is set fail safe Quote Link to comment Share on other sites More sharing options...
yoda69 Posted April 13, 2010 Author Share Posted April 13, 2010 Yeah, basically its exactly what I need. I'm running a psychological experiment so I need to find out how long a certain page with a specific psychological question was viewed and answered. The user is not supposed to go back to that page. Quote Link to comment Share on other sites More sharing options...
yoda69 Posted April 13, 2010 Author Share Posted April 13, 2010 What would be the actual syntax of timestamp ? Quote Link to comment Share on other sites More sharing options...
yoda69 Posted April 13, 2010 Author Share Posted April 13, 2010 Okay. Got it First page: $time1 = time() second page: $time2 = time() $totalTime = $time1 - $time2 Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted April 13, 2010 Share Posted April 13, 2010 Yeah if you want to be really accurate use microtime() (it gives an array, just add both together.) If it is a test, then it wil be by someone willing/interested - So you can assume most will follow your rules (not going back for ex.). But, they will cheat etc, but if its like an iq test it doesnt matter if they cheat, cuz if they arent honest it will be false anyway. I reccommend testing it yourself, and doing everything you can think of to it, then put it up on the website security check forum (or w/e), get people to tell you what they find is wrong. o btw - it helps if the topic is marked as solved. Cheers. -cb- Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.