Identify users
Connect anonymous visits to logged-in users for profiles, retention and journeys.
By default Stancelens is fully anonymous. When a user logs in you can call identify so their activity across devices and sessions is grouped into one user profile.
js
// After login / signup
stancelens("identify", "user_8231", {
name: "Ada Lovelace",
plan: "growth",
company: "Analytical Engines Ltd",
});- The first argument is your stable user ID. Prefer an internal ID over an email address.
- Traits are merged into the profile; later calls overwrite earlier values for the same key. If the site doesn't store personal data, traits such as
nameandemailare dropped or hashed (details). - Events from earlier in the same session are linked to the user, and the anonymous profile is merged into the identified one.
- The tracker remembers the ID in localStorage (
stancelens_uid) so later page loads stay identified.
Logging out
js
stancelens("identify", null); // or stancelens.reset(): back to anonymousPrivacy note
An identified user ID is personal data under GDPR. Mention Stancelens in your privacy policy and only identify users who are logged in to your product. Anonymous tracking stays cookieless and consent-free. See Privacy & GDPR.
Deleting a user
Erase a user with `DELETE /api/v1/users/:id`. It removes their events, sessions, profile and replays on that site immediately and permanently.