Time on Page
This code example can be used to determine the amount of time (in seconds) user spent on the page, before he closes it.
We've created an dummy API: https://topapi.free.beeceptor.com
to send post request
You can verify if the requests are being made here: https://beeceptor.com/console/topapi
The JavaScript API/feature which is used here is - Beacon API, which helps to send AJAX requests even after the page is unloaded