What is identify()
Theidentify() method associates a user ID with an anonymous visitor, creating a permanent link between all their activity before and after login.
Web:
When to Call identify()
Callidentify() whenever you learn who the user is:
After Signup
User ID Format
The user ID can be any string that uniquely identifies the user: Database ID:- Must be unique per user
- Must be consistent across sessions and devices
- Recommended: Use your database primary key
- Max length: 255 characters
User Traits
Traits are optional properties that describe the user.Standard Traits
Contact Information:Custom Traits
Add any traits relevant to your business:- Use snake_case for trait names
- Keep trait names consistent
- Don’t include sensitive data (passwords, SSNs, credit cards)
- Limit to 50 traits per call
Identity Resolution
When you callidentify(), DATALYR creates a permanent link between the anonymous ID and user ID.
Before identify()
Call identify()
After identify()
Cross-Device Attribution
Identity calls enable attribution across devices and browsers.Example: Multi-Device Purchase Journey
Mobile Phone (Day 1):user_789 and attributes the purchase to the original Meta ad (fbclid from Day 1).
Updating User Traits
Callidentify() multiple times to update user traits:
Initial Signup:
Reset Identity
Callreset() when a user logs out:
Web:
- Clears user ID from storage
- Keeps anonymous ID (device/browser still tracked)
- Next events tracked as anonymous until next
identify()
- User logs out
- User switches accounts
- Session ends
Server-Side Identification
Identify users from your backend:Identity Best Practices
Call identify() early and oftenTroubleshooting
identify() not working? Check:- User ID is non-empty string
- localStorage is available
- No errors in console
- Events appear in dashboard
- Same user ID used on all devices
identify()called after login on each device- User ID is consistent (not session-specific)
identify()called with new traits- Traits are valid JSON types (string, number, boolean, array)
- Not exceeding 50 traits per call
- All events from same anonymous_id → user_id
- Does NOT link events from different anonymous IDs unless both are identified with same user_id
Next Steps
Visitor Identification
Understand anonymous IDs
Events Overview
Learn about event tracking
Properties and Metadata
Add context to events
Cross-Domain Tracking
Track across domains