Visitor Identification API
What It Does
When you use the Identify API, LiveChatAI will:
- Match or create a Contact based on the provided data
- Populate the userβs Contact Attributes
- Enable attribute-based logic for:
-Behind-login user identification
-Segment-based content targeting (Enterprise only)
π
Contact Attributes are not used directly in chatbot responses but play a critical role in user segmentation and authentication workflows.
How to Use It
Place the identify call before your chatbot initializes:
<script>
window.lc = window.lc || {};
window.lc.debug = true; // Optional: Turn on for debugging; remove in production
window.lc.identity = {
distinctId: "{{USER:USER_ID}}", // Required: Unique identifier for your user
email: "{{USER:EMAIL}}", // Optional
name: "{{USER:NAME}}", // Optional
attributes: {
city_name: "{{USER:CITY_NAME}}",
browser_language: "{{USER:BROWSER_LANGUAGE}}",
user_id: "{{USER:USER_ID}}",
plan_id: "{{USER:PLAN_ID}}"
}
};
</script>
The attributes object accepts any custom Contact Attributes you've already defined in your dashboard.
Supported Attribute Data Types
- You can only pass attributes that already exist in your dashboard.
- New attribute keys must be created manually under Contacts > Attributes.
TypeScript Integration
If you're using TypeScript, define the structure as follows:
Interface
interface IdentifyEventData {
distinctId: string;
email?: string;
name?: string;
phone?: string;
attributes?: {
[key: string]: string | number | boolean;
};
}
Global Declaration
declare global {
interface Window {
lc: {
identity?: IdentifyEventData;
debug?: boolean;
};
}
}
Use Cases
- Authenticated sessions: identify logged-in users and show personalized flows.
- Segment targeting: enable dynamic content delivery via Segments (Enterprise only).
- Data enrichment: pre-fill user data in the inbox for more context and support continuity.
Best Practices
- Always call identify before chatbot initialization
- Make sure attribute keys already exist in your dashboard
- Avoid sending sensitive user data like passwords or personal identifiers
- Use distinctId consistently across sessions for accurate user tracking
For help setting up the Identify API or managing Contact Attributes, contact us at [email protected].