How to send events right before leaving page

You are here:
Estimated reading time: < 1 min

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 could be 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(event)

Where event 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.

Was this article helpful?
Dislike 0
Views: 11