coder500 Posted August 4, 2008 Share Posted August 4, 2008 Hi Is there any way to capture the time a visitor ends his visit on the website ( That is the time when he leaves the page(hitting back button or closing the window)) Thanks http://www.worth2read.org/ Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/ Share on other sites More sharing options...
JD* Posted August 4, 2008 Share Posted August 4, 2008 Not with much accuracy, unless you want to get into parsing log files. When a user leaves your site via closing the window, nothing is sent to the web server to indicate their leaving. As for leaving the site to go to another, you can parse the logs to see the last page and time the IP address was there, but you'd be constantly parsing the logs. Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/#findComment-607173 Share on other sites More sharing options...
revraz Posted August 4, 2008 Share Posted August 4, 2008 You can add an entry into a DB each time a user loads a page, and the last entry would be the last time used. Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/#findComment-607176 Share on other sites More sharing options...
coder500 Posted August 4, 2008 Author Share Posted August 4, 2008 Thanks for the reply. So no other way to know when he closes the window? Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/#findComment-607178 Share on other sites More sharing options...
revraz Posted August 4, 2008 Share Posted August 4, 2008 You can look into Javascript and see if it can do a onclose event. But I wouldn't rely on it too much. Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/#findComment-607182 Share on other sites More sharing options...
PFMaBiSmAd Posted August 4, 2008 Share Posted August 4, 2008 It turns out that IE will let you request a URL in an onclose event (close does not mean close), but FF won't (close does mean close.) I tested this some time ago. The best suggestion I have seen would be to use AJAX to periodically request a URL (once every 30/60 seconds...) that is used to update the last active time. Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/#findComment-607298 Share on other sites More sharing options...
JonnyThunder Posted August 4, 2008 Share Posted August 4, 2008 Im sure you could use onClose event handler along with an ajax script to log when the page is closed. Though really, it's overkill when you can just log the last page activity. Link to comment https://forums.phpfreaks.com/topic/118025-time-a-vistor-leaves-the-webpage/#findComment-607329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.