matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.83k stars 2.64k forks source link

Hearbeat doesn't work accurately for users that use multiple tabs #22480

Open aimgazer opened 2 months ago

aimgazer commented 2 months ago

Hi there!

Heartbeat times doesn't stop tracking time when users switch tabs. This leads to an overestimate for avg. time on page and makes website optimization challenging.

Example for a page with heartbeat timer: T0: User enters the page which starts the timer. T1: User opens another tab and leaves the current tab including the page that Matomo is tracking. Heartbeat timer communicates time on page accurately to Matomo. T2: User returns to the tab which featured the page that Matomo is tracking. This starts the issue. T3: When user closes the tab or leaves the tab to use another tab, heartbeat timer reports the entire duration (T3-T0). This is incorrect, the duration to be reported is (T1-T0)+(T3-T2). Since Matomo has access to all these events, the correct timing should be easy to calculate.

Fixing this will correct avg. time on page reporting for all Matomo users since most users are leveraging multi-tab browsing. Currently, the higher end values in time on page metric can be quite off which can lead to an inflated avg. time on page. This is important since avg. time on page is one of the most frequently tracked and optimized metrics by product teams.

This was also reported as a bug here: https://forum.matomo.org/t/heartbeat-timer-tracks-when-tab-is-minimized/50004 We are using Matomo 4.13.3.

Thank you!

des-innocraft commented 2 months ago

Hi @aimgazer . Thank you for creating the issue and bringing this to our attention, that's very appreciated. We have reviewed and triaged this ticket internally. Our team will prioritise this, and we will update you on the progress here when we have an update to share. If you have any further information or questions, please feel free to add them here.