Identify users
Link visits and events to the users of your product.
Without cookies, Loomduct knows a visitor only for one day. When a user signs in to your product, call identify() with your own user id. Loomduct then links the visitor, with the events from before the sign-in, to that user.
Before you start
- Loomduct installed on your site. See the Quick start.
- A user id from your app, like the id in your database. Use a string:
'42', not42.
Steps
Call identify() after sign-in
import { loomduct } from './loomduct'
await loomduct.identify('user_42', {
name: 'Jane Doe',
email: 'jane@example.com',
plan: 'pro',
})With the script tag, call loomduct.identify(...) the same way.
Call it again on every page load
The SDK keeps nothing on the device, so it forgets the user when the page reloads. Call identify() on every page load where the user is signed in. A call with the same user id and properties as the last one on the page is skipped, so it is fine to call it on every render or route change.
Properties
- Properties are saved on the user and merged: keys you send overwrite old values, keys you leave out stay.
- Set a property to
nullto remove it:loomduct.identify('user_42', { plan: null }). - The same rules as for event properties apply.
userIdcounts as one of the 30 properties. - These properties do not go through
beforeSend. Only send what you want stored. - A
nameproperty is shown as the user's name in the dashboard.
identify() never throws and its promise never fails. If the request fails, the error goes to onError, so your sign-in flow keeps working.
Check that it worked
Sign in on your site. In the dashboard, open Visitors. Your visit shows Identified in the Type column. Open it to see the user's name and properties.