analytics.js
analytics.js copied to clipboard
how to clear segment data when window closes
Is there a way to do a reset when the tab closes, Right now I store my user in sessionStorage, when I close the tab the user logs out. However the segment user id is still there.
Thanks
@acollazomayer have you tried hooking into the page unload event and reseting analytics? Something like this:
window.addEventListener('unload', function() {
window.analytics.reset();
});
@pooyaj Tried it, but session storage does not get clear on refresh. On beforeUnload or unload are triggered on refresh