NeoMarine Posted August 17, 2008 Share Posted August 17, 2008 Do you have any ideas on how to record the time spent on a page? I have a website which allows people to play games (for example) and I want to track how long they are on the "play game" page before exiting/browsing to another page or closing window. I know that Google Analytics can do this, but how? Link to comment https://forums.phpfreaks.com/topic/120058-time-spent-on-page/ Share on other sites More sharing options...
MasterACE14 Posted August 17, 2008 Share Posted August 17, 2008 not a accurate way as such, but.... you could store the time they entered the page in a session variable, and do the same for each page. With that you can workout the time in between to give you how long they were on the page. Otherwise.... If you want it to be dynamic. Use Javascript or AJAX. Link to comment https://forums.phpfreaks.com/topic/120058-time-spent-on-page/#findComment-618470 Share on other sites More sharing options...
NeoMarine Posted August 17, 2008 Author Share Posted August 17, 2008 The first method you mentioned will not work for my specific scenario, as they would open a "pop-up" window and it does not navigate to anywhere else, so I would not be able to track the time "after" since I could only store a session at the beginning, when they opened the "pop-up" window. Do you know any specific javascript/ajax related methods? I cannot find a solution through search engines or forums. Link to comment https://forums.phpfreaks.com/topic/120058-time-spent-on-page/#findComment-618499 Share on other sites More sharing options...
mrMarcus Posted August 17, 2008 Share Posted August 17, 2008 you could just manipulate a javascript countdown/clock function that executes whatever you like once the clock hits your predetermined time. by the sounds of it, you're looking for some JS code. Link to comment https://forums.phpfreaks.com/topic/120058-time-spent-on-page/#findComment-618569 Share on other sites More sharing options...
cooldude832 Posted August 17, 2008 Share Posted August 17, 2008 2 Javascript function onLoad onUnload the onLoad inserts a row into the mysql table and then returns the inserted id as a JS variable. onUpload uses the inserted id variable to update that row unload time as NOW() (the onload time you set to NOW() on the load Link to comment https://forums.phpfreaks.com/topic/120058-time-spent-on-page/#findComment-618574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.