Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigator.sendBeacon() doesn't send ping on mobile devices when browser tab is closed/tab switched/app closed #17978

Closed
Starker3 opened this issue Sep 8, 2021 · 3 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.

Comments

@Starker3
Copy link
Contributor

Starker3 commented Sep 8, 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
@Starker3 Starker3 added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Sep 8, 2021
@tsteur tsteur added Bug For errors / faults / flaws / inconsistencies etc. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Sep 8, 2021
@tsteur tsteur added this to the 4.6.0 milestone Sep 8, 2021
@tsteur
Copy link
Member

tsteur commented Sep 8, 2021

Thanks for creating the issue @Starker3 👍

@heurteph-ei
Copy link

heurteph-ei commented Sep 8, 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 tsteur removed this from the 4.6.0 milestone Sep 8, 2021
@tsteur tsteur added the duplicate For issues that already existed in our issue tracker and were reported previously. label Sep 8, 2021
@tsteur
Copy link
Member

tsteur commented Sep 8, 2021

@Starker3 actually this is a duplicate of #17978 so closing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. duplicate For issues that already existed in our issue tracker and were reported previously. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.
Projects
None yet
Development

No branches or pull requests

3 participants