To track time spent by website visitor on a given page, we will be using javascript’s onbeforeunload event. The onbeforeunload event occurs when the document is about to be unloaded. So as soon as the page loads, a start time is stored in a variable and just before unloading, the end time is stored in another…

read more