Identify and track users across sessions with persistent user IDs and properties
identifyUser()
- Instance Method (Recommended)Promise<string>
- The endUserId of the identified user
identifyUserGlobally()
- Global FunctionPromise<string> | null
- The endUserId if successful, null if tracker not found
identifyUser
after successful login or signup, not during page initialization.Property/Option | Type | Description |
---|---|---|
endUserId | string | Unique user ID (auto-generated and stored in a cookie by default). |
identifyUser() | function | Identify user with properties (returns Promise<string> ). |
identifyUserGlobally() | function | Global user identification function (returns Promise). |
userProperties | object | Any key-value pairs (e.g., email , name , plan , etc.). |
cookie | string | Stores user ID for 365 days. |
identifyUser({ userProperties })
fields:
Field | Type | Description |
---|---|---|
Any | any | You can provide any user property fields. |
Example: | ||
email | string | User’s email address. |
name | string | User’s name. |
userId | string | Your internal user ID. |
plan | string | User’s plan or segment. |
Method | When to Use | Returns | Notes |
---|---|---|---|
tracker.identifyUser() | You have tracker instance | Promise<string> | Most common, direct access |
identifyUserGlobally() | No tracker access, global usage | Promise<string or null> | Works from anywhere, requires global tracker |