How 'Time Spent on Page' is calculated

Hello. I’m particularly interested in how the total time spent on pages is calculated. For instance, if a person were just to remain logged in on the site Matomo is tracking and not commit any actions on that page, would “Time Spent on Page” for that user continue to be calculated? Is there a way after a certain set of minutes their session is declared inactive as to not be counted in the averages of time on pages? Help!


The way it works was rewritten recently. You can see it here:

  • Ping only on window blur (never on focus)
  • On window blur send only a request if the user was on the page for at least 15 seconds (or whatever is configured as heart beat timeout). Otherwise user maybe was just quickly switching between tabs but not actively on the page
  • Ping on unload of browser window but only when user was on page > 15 seconds (or configured heart beat timeout)
  • Stop sending ping requests 30 minutes after the first request (as it would not have any effect anyway)
  • Now requiring at least 5 seconds to be configured as heart beat timer as every second be quite extreme and we want to prevent this.