Skip to content
  • There are no suggestions because the search field is empty.

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.

When to Use Identify

  • 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

Basic Usage

_oirtrk.push([
'identify',
{
email: 'user@example.com',
first_name: 'John',
last_name: 'Doe',
},
]);
 

User Data Properties

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

Address Object

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.

Examples

User Registration

_oirtrk.push([
'identify',
{
email: 'customer@example.com',
first_name: 'Jane',
last_name: 'Smith',
},
]);
 

Checkout Identification

_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',
},
},
]);
 

Newsletter Signup

_oirtrk.push([
'identify',
{
email: 'subscriber@example.com',
},
]);
 

With Custom Properties

_oirtrk.push([
'identify',
{
email: 'user@example.com',
customer_segment: 'premium',
lifetime_value: 1500.0,
subscription_tier: 'gold',
signup_source: 'landing_page',
},
]);
 

Framework Integration

React

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 Submission

<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>
 

Best Practices

1. Include Relevant Data

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',
},
]);
 

2. Validate Data

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);
}
 

3. Privacy Compliance

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]);
}
 

4. Avoid Duplicate Calls

Debounce identify calls to prevent duplicates:

let identifyTimeout;
function debouncedIdentify(userData) {
clearTimeout(identifyTimeout);
identifyTimeout = setTimeout(() => {
_oirtrk.push(['identify', userData]);
}, 300);
}
 

Event-Level User Data

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.

Example: E-commerce Checkout

_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',
},
},
]);
 

Important Considerations

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 identify method when you want the data to persist and sync across tabs.

Troubleshooting

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

Next Steps