How to track events right before leaving page

There are situations where API calls to send events to our servers are canceled by browser leaving current page. The most common one is form submits.

When you know this is happening (track an event, for example click on a button redirects to another page), instead of sending the event using _vteq.push, call the method below:

_vtsdk.eventApi.pushNext(e)
Where e has the usual event format. This event will be sent immediately on the next page load.
Warning: do not use this method multiple times on a page, because only last call to it will be considered and saved.

Related Articles