Tracking spent time on page and then send it to my Xano Backend before page is closed

Hi,

I need to track spent timed on every page on my webapp. In Weweb we use TimeJs to calculate the correct time excluding idle. This work like a charm.

Next, i need to update a row in a xano table when user is leaving. My problem is we can make a workflow on page unload, but the api call is not processing when the user close the tab. I can only update time spent when user change tabs for now, which is a problem for me.

Is there a way to achieve it ?

I saw TimeMe can use websocket, but xano don’t for now :frowning:
I saw the eventListener onbeforeunload but don’t know how to add this eventListener on weweb.

Thanks you for your help

Easiest way for you to do this is use the Weweb Before Unmount event in the page workflows

If you cannot use that, then you can just add a before unmount listener using custom JS

Thanks for the answer