Events triggered on 'beforeunload' event, not always post data right away

Is it valid statement that if i post events to countly which should be triggered on beforeunload event they will not be posted immediately?


Imagine we have following code:

function countlyTrackTabClose() {
key: 'tabClose',
segmentation: {
someProp: 'demo',
someOtherProp: 'demo 2'
window.addEventListener('beforeunload', countlyTrackTabClose);

If user will close tab(this event will be triggered on page refresh also but lets discuss only tab close case), will this event be sent right away or it may be sent after user will open web site next time?





1 comment
  • Official comment

    Hello Andrii,

    Thanks for reaching out. It depends on what is in the queue already and how the browser closes the tab. In most cases, it will not be right away but in the next session but in some cases, it can make a request right away.

    Comment actions Permalink

Please sign in to leave a comment.