How do I add a Javascript heartbeat timer to measure time spent by visitors on my pages, including the last page of their visit?
By default, Matomo will accurately track the time spent on all your pages, except the last page view of the visit, as Matomo counts the “Time spent on page” as 0 seconds by default.
When your visitor views only one page in the website, the “Visit” duration will also be 0 seconds by default.
If you wish to use another default visit duration time, you can achieve this by changing the config flag default_time_one_page_visit
. (This will not affect the “Time spent on page”)
-> It is possible to configure Matomo to track the time spent in the visit accurately (the “Visit duration” metric), and including the time spent in the last page view of each visit.
Learn more about heartbeat (heart beat) timers in the JavaScript Tracking code guide.
Next FAQ: How do I find the visitor IP Addresses?