recently encountered a problem when doing the front-end burying point, the need is to count the length of time the page stays and the time it takes to leave the page.
so I want to trigger a buried point request when the user leaves the current page. I try to use the beforeunload event, but there are always some problems.
I wonder how other plug-ins count the length of stay on the page, whether the front end records the time when the user leaves the page, or the time it takes to enter the second page in the background minus the exposure time of the first page.
ask God to tell me, thank you!