Identifying Users
Call identify() when you know who the user is — after login, form submission, or checkout. This links their anonymous browsing history to their profile.
Usage
sunrise.push(['identify', {
email: '[email protected]',
phone: '+15551234567', // E.164 format
external_id: 'cust_123' // Your internal customer ID
}]);Fields
| Field | Type | Description |
|---|---|---|
email | string | Email address — most important for marketing |
phone | string | Phone in E.164 format (e.g., +15551234567) |
external_id | string | Your internal customer/user ID |
At least one identifier is required. Providing multiple identifiers improves profile matching accuracy.
When to Call
- After login — User authenticates on your site
- After form submission — Newsletter signup, lead capture
- At checkout — When the user enters their email/phone
- On page load — If you already know the user (e.g., from a session cookie)
// Example: identify after a form submission
document.getElementById('signup-form').addEventListener('submit', (e) => {
const email = e.target.querySelector('[name="email"]').value;
sunrise.push(['identify', { email }]);
});How It Works
When identify() is called, the SDK sends the identifiers to the Postscript identity resolution service, which:
- Finds or creates a profile matching the provided identifiers
- Merges any anonymous events from the current session into that profile
- Returns a resolved profile ID used for all subsequent events in the session