I'm using navigator.sendBeacon
on the front end to tell the server when a user enters and leaves a page (via window.load
and window.unload
). I'm recording the time of arrival/departure server-side. I'm noticing some instances where there is an arrival time but no departure time.
Are there common circumstances, i.e., not a browser/system crash, under which the window.unload
event fails to fire? Perhaps on redirects, back button, or navigation away from a page before all content has loaded?
No there is no conditions, outside of browser/system crashes, where the window.unload event will fail to fire. It is supported in all major browsers and many previous versions of all major browsers.