@Starker3 opened this Issue on September 8th 2021

Expected Behavior

When using _paq.push(['alwaysUseSendBeacon']); we would expect to be able to track an accurate time on page for all devices.
(This is already enabled by default, but even when defining a lower time for the sendBeacon such as a few seconds doesn't change the behaviour)

Current Behavior

Currently this seems to work for desktop browsers. However, mobile devices seem to not send a ping request when the tab is closed, the tab is switched or when switching to a different app on the mobile devices.

This causes inaccurate time on page metrics for all mobile devices for the last page in the visit as well as inaccurate visit lengths when a visitor only views a single page.

Possible Solution

I don't know the exact method that is currently being used for the sendBeacon, but the Mozilla docs: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon recommend to use visibilitychange event instead of unload or beforeunload
https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event

Your Environment

  • Matomo Version: 4.4.1
@tsteur commented on September 8th 2021 Member

Thanks for creating the issue @Starker3 👍

@heurteph-ei commented on September 8th 2021

The thing is that sometimes, the page session must not be ended when I switch tab or minimize he browser... Personally, I often switch app / tab to get additional data in order to finish the filling of a form for example...
Or maybe create a kind of rollback in the page session end? Or else a maybe-page-session-end event...
Cases study of maybe-page-session-end event:

  • There is another event in the same page within the page session timout duration -> It was not really a page-session-end event, must be understood as a ping
  • There is no other event in the same page within the page session timout duration -> It was really a page-session-end event, must be understood as a page-session-end
@tsteur commented on September 8th 2021 Member

@Starker3 actually this is a duplicate of https://github.com/matomo-org/matomo/issues/17978 so closing it.

This Issue was closed on September 8th 2021
Powered by GitHub Issue Mirror