Ending or Aborting a Session

Two calls control the current session:

  • uxc.stopSession() ends the session and uploads it. The next interaction starts a new session.
  • uxc.abort() discards the session: it is not uploaded and recording stays off until the next page load.

Ending the Current Session

uxc.stopSession()

Ends the current session and uploads it, without reloading the page. Use it when one browser tab serves many people one after another, such as a kiosk or a shared device: call it when one person finishes (for example after payment, when the screen returns to the start), so each person gets their own session. The method takes no parameters.

// Example: kiosk, one session per customer
function onOrderFinished() {
  uxc.stopSession();
  // properties don't carry over: set them again for the next session
  uxc.setUserProperties({ store: 'STORE_ID', kiosk: 'KIOSK_ID' });
}

What to expect:

  • The session is uploaded and appears in your dashboard like any other.
  • The next click, tap, key press or scroll starts a new session about a second later. That first interaction is not recorded; the new session starts on the screen that follows it.
  • User properties are not carried over to the new session. Set them again right after uxc.stopSession().
  • All sessions in the same browser keep the same anonymous user unless you call uxc.setUserIdentity with a different ID.
  • A page reload does not start a new session on its own; the session continues across reloads. Use uxc.stopSession() when you need a clean break.
  • If you might call it before the SDK has loaded, add stopSession: function() { this.__t.push(['stopSession']); }, to the window.uxc object in the snippet.

To stop recording the current session and prevent it from being uploaded, call uxc.abort(). Use it when a user withdraws consent, for internal or test traffic, or on pages you never want recorded.

Aborting the Current Session

uxc.abort()

Stops recording and closes the connection. The session is not uploaded, does not appear in your UXCam dashboard, and does not count towards your session quota. The method takes no parameters.

uxc.abort();

//Example: don't record internal pages
// (wait for 'load' so the SDK is ready)
window.addEventListener('load', () => {
  if (window.location.pathname.startsWith('/admin')) {
    uxc.abort();
  }
});

What to expect

  • Recording does not restart on its own. After uxc.abort(), further clicks, scrolls or navigation within the same page load are not recorded.
  • The next full page load (a refresh, or opening the site again) starts a new session as usual. If a user should stay unrecorded, call uxc.abort() again on each page load.
  • Single-page apps navigate without a page load, so the abort lasts until the user reloads.

Tip

Call uxc.abort() as early as possible, ideally before the user interacts with the page, so that nothing has been sent yet.


Did this page help you?