Sending data to index through vega or by any other kibana feature

I want to calculate that how much an user spent time on a particular dashboard
i have created a timer through vega ( working)
now want to send this timer data when user closes/leaves the dashboard so that I can use this data
any idea ?