0s pageviews, even though heartbeat time is enabled

Hi there,

my heartbeat timer is enabled and set to two seconds, which works for 70% of all users. However, I’m still getting a view 0s pageviews. This is the tracking code in Borlabs:

<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['enableHeartBeatTimer', 2]);

(function() {
var u="%%matomoUrl%%";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '%%matomoSiteId%%']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
<!-- End Matomo Code -->


Shows 0s on the site.

What could the problem be?


Matomo only sends the heartbeat after at least 15 seconds (which you can change).

Is it possible that 30% of the visitors leave the website in less than 15 seconds?



that could be possible, however, I’ve configured Matomo to send the heartbeat after 2 seconds:
_paq.push([‘enableHeartBeatTimer’, 2]);

Hi I have the same problem. I set the time to 5

1 Like

Note: The delay can’t be lower than 5. If you pass a lower value Matomo will automatically use 5


Ohh okay, so you think the 0s pageviews are all page views under 5 seconds? There’s no way to further improve that?

Might be possible to do that with a custom javascript. Something like this could work
window.addEventListener('beforeunload', Matomo.getAsyncTracker.ping);

But that might actually also cause 2 ping requests if the unload is triggered after the configured delay…