Cross-page browsing time statistics

problem description

there are three ABC, pages under a domain name, and there are links to other domain names in the C page. The entry of the web page is page A, and you need to count the browsing time under the domain name (start when the page enters, close the page). The definition of a closed page is to click back on page An or close it directly on the BC page

.

the environmental background of the problems and what methods you have tried

the existing solution is to create a new page D, where page D contains iframe nested page A, monitor page D with onbeforeunload and onpagehide, and send an ajax request to the backend after the page is closed.

disadvantages

but now I find that iframe has a lot of weird bug, on IOS that needs to be adjusted to the ABC page to fit the iframe under IOS.

is there any good way to deal with the need for cross-page browsing time statistics?

Sep.06,2021

Why not think differently.
starts timing after passing the page load, and then captures the a tag click and the browser's onbeforeunload event


Thank you for the invitation.

there are no good ideas, so let's refer to the article:

if you are not afraid of too much pressure on the server, one ajax per second to the server. If the radis, is not updated for more than 3 seconds, it is considered that the user leaves
precision is not required. Once per minute is fine. If the server is not updated for more than 3 minutes, the user leaves

.
Menu