User Identification Guide
Learn how to identify users with the OIR SDK.
The identify method allows you to associate user data with their tracking identity. Use this when a user logs in, signs up, or provides their information. This enables better tracking, personalization, and analytics.
- User Login: When a user logs into your application
- User Signup: When a new user registers
- Profile Updates: When user information changes
- Checkout: When a user provides their information during checkout
- Newsletter Signup: When a user subscribes with their email
_oirtrk.push([
'identify',
{
email: 'user@example.com',
first_name: 'John',
last_name: 'Doe',
},
]);
| Property | Type | Description |
|---|---|---|
email |
string | User's email address |
phone |
string | User's phone number |
first_name |
string | User's first name |
last_name |
string | User's last name |
address |
object | User's address information |
[custom] |
any | Any custom user property |
| Property | Type | Description |
|---|---|---|
first_name |
string | First name for address |
last_name |
string | Last name for address |
street |
string | Street address |
city |
string | City |
state |
string | State or province |
zip |
string | ZIP or postal code |
country |
string | Country code |
Note: Provide at least one identifier (email or phone) for identify to work properly.
_oirtrk.push([
'identify',
{
email: 'customer@example.com',
first_name: 'Jane',
last_name: 'Smith',
},
]);
_oirtrk.push([
'identify',
{
email: 'customer@example.com',
phone: '+1234567890',
address: {
first_name: 'Jane',
last_name: 'Smith',
street: '123 Main St',
city: 'San Francisco',
state: 'CA',
zip: '94102',
country: 'US',
},
},
]);
_oirtrk.push([
'identify',
{
email: 'subscriber@example.com',
},
]);
_oirtrk.push([
'identify',
{
email: 'user@example.com',
customer_segment: 'premium',
lifetime_value: 1500.0,
subscription_tier: 'gold',
signup_source: 'landing_page',
},
]);
import { useEffect } from 'react';
function UserProfile({ user }) {
useEffect(() => {
if (user) {
window._oirtrk.push([
'identify',
{
email: user.email,
first_name: user.firstName,
last_name: user.lastName,
},
]);
}
}, [user]);
return <div>User Profile</div>;
}
<form id="registration-form">
<input type="email" name="email" required />
<input type="text" name="firstName" required />
<input type="text" name="lastName" required />
<button type="submit">Register</button>
</form>
<script>
document.getElementById('registration-form').addEventListener('submit', function (e) {
e.preventDefault();
var formData = new FormData(e.target);
window._oirtrk.push([
'identify',
{
email: formData.get('email'),
first_name: formData.get('firstName'),
last_name: formData.get('lastName'),
},
]);
// Continue with form submission
});
</script>
Always include as many relevant properties as available:
// ✅ Good - comprehensive identification
_oirtrk.push([
'identify',
{
email: 'user@example.com',
first_name: 'John',
last_name: 'Doe',
phone: '+1234567890',
},
]);
function identifyUser(userData) {
if (userData.email && !isValidEmail(userData.email)) {
console.error('Invalid email format');
return;
}
_oirtrk.push(['identify', userData]);
}
function isValidEmail(email) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}
Ensure compliance with privacy regulations (GDPR, CCPA):
function identifyUserWithConsent(userData, hasConsent) {
if (!hasConsent) {
console.warn('User has not provided consent');
return;
}
_oirtrk.push(['identify', userData]);
}
Debounce identify calls to prevent duplicates:
let identifyTimeout;
function debouncedIdentify(userData) {
clearTimeout(identifyTimeout);
identifyTimeout = setTimeout(() => {
_oirtrk.push(['identify', userData]);
}, 300);
}
User profile data can also be attached directly to event payloads instead of using the identify method. This is useful for one-time events where you want to include user information without persisting it.
_oirtrk.push([
'event',
{
event: 'begin_checkout',
ecommerce: {
currency: 'USD',
value: 99.99,
items: [{ item_id: 'SKU123', item_name: 'Product', price: 99.99, quantity: 1 }],
},
billing: {
first_name: 'John',
last_name: 'Doe',
email: 'john@example.com',
phone: '+1234567890',
address_1: '123 Main St',
city: 'New York',
country: 'US',
postal_code: '10001',
},
},
]);
| Aspect | identify Method |
Event-Level Data |
|---|---|---|
| Persistence | Stored in browser, persists across sessions | Not stored, only sent with that event |
| Cross-Tab Sync | Synchronized across all open tabs | Not synchronized |
| Form Alignment | Aligns with other forms and identify calls | Not aligned with other data |
| Use Case | User login, signup, profile updates | One-time event data, guest checkout |
Note: Event-level user data is not persisted in the browser and will not be used or aligned with other forms or identify calls. Use the
identifymethod when you want the data to persist and sync across tabs.
Identify not working?
- Ensure the SDK is initialized before calling identify
- Verify the data format is correct
- Check the browser console for errors
Multiple identify calls?
- Use debouncing to prevent rapid duplicate calls
- Ensure you're not calling identify on every render
- Cross-Tab Sync Guide - Learn about cross-tab synchronization
- Custom Events Guide - Track custom events
- Installation Guide - Install and configure the SDK