0

Hello Daniweb,

I want to make a custom visitor tracking tool and like Google Analytics it must be able to track how long time visitors spend on each page.

How do you recommend doing this?

I thought of using the Javascript onload event to start counting time serverside and then the onbeforeunload event to do tell the server to end the time count. I'm just skeptic of an infinite visit duration if the visitor's browser for some reason doesn't call the event (ie power outage).

Any ideas? I'm using PHP server side and looking for a most cross browser compatible solution.

I am aware that precise measurement of this is not possible.

Kind regards,

Excizted

Edited by Excizted: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by tinymark
0

You could use any server side techonology to do that if you want to implement it from scratch by yourself. One problem that you need to solve is that how would you know that a visitor is still spending time on a page of your website. For example, a user opens your web page and left to do something else. Another case is when a user opens your web page and close the browser. I am guessing that one way to do it is to compute from the first request is made until the time out... Not sure...

0

Try something in ajax/javascript/jquery/php or your choice and have the page ping the server every 'whatever you decide is reasonable' seconds with the SESION_ID you created in php. I would setup every page so they all ping a specific page with the SESSION_ID.

Register each SESSION_ID with the page. I would make a new timer from my timer class that is reset if the ping comes back and fires off the time spent to wherever I needed it.

I know its all theory and easy to say.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.