-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Consider reverting tracker to navigator.sendBeacon() #1470
Comments
Hello, given your testing code, Results would probably be on par if you test with fetch and keepalive
Would be interesting to see the results 👍 |
Ah, from reading #1160 I was assuming that |
Here's a new summary, including
|
Btw, for the new case (2.) I used exactly what @Maxime-J suggested:
|
And it was for a little while, not in But I follow you, tracker needs a way to send events in a persistant way. |
But this will still not improve the visit duration accuracy. This will only solve the persistence issue faced by the For improving the accuracy of the visit duration, we would need a way to remember when the user actually leaves the site, this can be done by doing some database changes. I proposed this on #570 (comment). |
@rohandebsarkar Moving to sendBeacon is not sufficient, but it would be a step in that direction. Umami users could then store events on page leave and use data in their database to manually calculate their visit duration following their (arbitrary) definition. |
@rohandebsarkar Regarding #1471: Are you also considering the |
The tracker has been updated to no longer use fetch keepalive (doesn't work in Firefox) or navigator.sendBeacon (blocked by all adblockers). Update will be in the next release. |
Fixed in v1.38.0. |
In #1160, it was proposed to switch from
navigator.sendBeacon()
in the tracker tofetch()
withkeepalive: true
. The goal was to avoid some ad blockers from preventing analytics data to go through. This change was implemented in #1163.I was thinking about the visit duration accuracy issues (#570, #1047) and have found some limitations with the
fetch
approach, especially if, as suggested by @gnarlex here, we want to send an event when a visitor leaves:Unfortunately,
fetch()
even withkeepalive: true
does not send events reliably onvisibilitychange
events. I've done some testing with the following code and include my results below:Note that
fetch()
only sends the event reliably when the web application is still alive. (Browser versions: Chrome v104, Firefox v103, Safari v15.3, Mobile Safari v15.6)Switching (back) to
navigator.sendBeacon()
improves the results substantially:This is much better: we now have post-mortem events in many cases. Based on this, I propose reverting to
navigator.sendBeacon()
. In order to avoid the ad blocking problems, we could addfetch
as fallback, as @rohandebsarkar suggested in #1160.What do you think?
The text was updated successfully, but these errors were encountered: