I'd like to track time when user is interacting with the page. As far as I understand user can basically leave a page by
- Navigating away (back/forward)
- Closing window
- Opening new tab and just keeping the old tab in the background
- Switch tabs/windows
While I understand I can use "onbeforeunload" for 1 and 2, what can I do about 3 and 4? From my experience it's pretty usual to see people with many tabs open all the time in Chrome/Edge but interacting only with one. Is there any nice trick how to find out that user "deactivated" tab/window?