Support Forum Support Forum User Activity Tracking and Log What are all the scenarios in which a browser session would be terminated?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • October 10, 2023 @ 2:35 pm

    Like other users, I’ve noticed I have a lot of “N/A” in the duration of my log.

    I’ve been trying to test and come up with ways that would duplicate this issue.

    These are the scenarios I have found:

    • If I go to my site and then completely close the browser, that time will not show up.  If I open my site in a tab and have another site open in another tab and I close the tab to my site, the time will show up.
    • I also discovered if I go to my site on my phone and then just open up other apps and put the phone down, that time will not show up.

    Does anyone else have any scenarios that would duplicate the “N/A” in the time duration?

    Moove Agency
    October 16, 2023 @ 1:38 pm

    Hello,

    In our plugin we’re using the beforeunload event. You can find more details about this listener here:

    https://dev.to/chromiumdev/sure-you-want-to-leavebrowser-beforeunload-event-4eg5

    This beforeunload event is supported by all browsers, but there are differences. Some of them have “sendBeacon” function, in this case our plugin could send the time tracking to our plugin asynchronously, while with other browsers where the sendBeacon is not an option we’re using an AJAX call.

    So when user closes the browser / tab the browser sends a “signal” to our plugin that the session is terminated and our plugin then adds a record into the SQL table.

    This process is PHP generated, but if the browser window was closed in an abrupt way (ie. quitting the entire browser or by closing the laptop) then our plugin doesn’t have enough time to save this record to the database, and the time tracking screen will display N/A.

    Unfortunately this is out of our control, there are no other ways as we can’t delay the “closing browser” action by our plugin.

    Hope this makes sense.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘What are all the scenarios in which a browser session would be terminated?’ is closed to new replies.