Sign out and switch users
Start a new visitor when a user signs out or another user signs in.
When a user signs out, call reset(). Later events are then not linked to that user, and the browser gets a new visitor.
Before you start
- Loomduct installed on your site. See the Quick start.
- Users identified with
identify().
Sign out
Call reset() in your sign-out flow:
import { loomduct } from './loomduct'
loomduct.reset()
window.location.href = '/login'You do not need to wait for reset() before you redirect: the request keeps going when the page changes. Events sent right after reset() wait until the new visitor id arrives, at most 2 seconds, so they are never linked to the old user.
Other open tabs of your site keep the old visitor until they reload.
Switch users
If a user can switch accounts without signing out, call reset() before identify() with the new user. Otherwise both users are linked to the same visitor.
await loomduct.reset()
await loomduct.identify('user_99')Check that it worked
Sign out on your site, then open another page. In the dashboard, open Visitors. The new page view belongs to a new anonymous visitor, not to the user.