identify
Gripz('identify', user, options?)Tells Gripz who the current visitor is. Call it after sign-in, and again whenever the person's details change. Earlier anonymous conversations are merged into the contact.
Parameters
| Name | Type | Description |
|---|---|---|
| user.id | string, required | Your own stable ID for this person. Do not use an email address, because emails change. |
| user.token | string | A JWT signed on your server. Required when identity verification is enforced for the workspace. |
| user.email | string | Used for email replies when the person is away from your site. |
| user.name | string | Shown to teammates in the inbox. |
| user.attributes | object | Custom attributes, up to 50 keys. Values are strings, numbers, booleans or ISO 8601 dates. |
| options.merge | boolean | Merge this browser's anonymous conversations into the contact. Default true. |
Example
// Ask your own server for a signed token
const token = await fetch('/api/gripz-token').then((r) => r.text());
const contact = await Gripz('identify', {
id: 'usr_4821',
email: 'elena@brightloop.studio',
name: 'Elena Marchetti',
token,
attributes: { plan: 'studio', invoicesSent: 214 }
});Returns
A promise that resolves with the contact once the server has accepted the identity.
{ contactId: 'ct_9d3m', verified: true, mergedConversations: 1 }Errors
| identity_required | Verification is enforced and no token was sent. The visitor stays anonymous. |
|---|---|
| identity_token_invalid | The signature, expiry or user ID did not match. Paste the token into the validator to see which check failed. |