@heurteph-ei Unfortunately I didn’t find a solution for this yet. Ideally if the user leaves a site (minimizes the browser or changes the tab) and then comes back after 10 minutes the time on site should start again and should be inactive while the tab is not in focus. So for example I’m 1 minute on the site and then change the tab, the timer should stop until the site is in focus again. Otherwise I get way too high times on site that don’t reflect the user engagement and destort the average time on site.
@melbao I also tried to implement the heartbeattimer with your latest suggestion. I included it like this via Matomo Tag Manager with a custom HTML tag:

Unfortunately this way, I don’t get any pings that influence the time on site.