Visit Duration for Single Page website

I have a website page where most of the visitor will spend their time on. The site uses PHP with Codeigniter and jQuery.

However, I believe tracking systems like Piwik calculate the time spent on a page by subtracting the time the visitor leaves that page to a new page from the time he loads the page.

Is there a way around this? Maybe use javascript to trigger Piwik on exiting the page so it knows that the visitor is leaving the page?

Feature request Support Ping requests to report a better 'time on page' · Issue #2041 · matomo-org/matomo · GitHub

Awesome… cant wait for this feature!!