User identification
Turn anonymous visitors into persistent and searchable profiles along with custom parameters.
Profiles track your users with persistent IDs (like email
or userId
) and provide several advantages:
- Cross-platform tracking: Follow users across browsers and devices
- Search visitors: Find specific users and their journeys in your analytics dashboard
- Persistent tracking: Maintain user journey even if cookies are reset
- Better attribution: Link anonymous traffic to known users
How to identify a user
Use the window.datafast()
method to identify a visitor:
window?.datafast("identify", {
user_id: "unique-user-id", // required
name: "John Wayne", // optional - if present, it will replace the anonymous name in the visitor profile
// ... any other custom parameters you want to track
});
Required parameters
user_id
(string, required): A unique identifier for the user like email or userId
Special parameters
name
(string, optional): If present, it will replace the anonymous name in the visitor profile
Custom parameters validation rules
- Property names: lowercase letters, numbers, underscores (_), and hyphens (-) only. Max 32 characters.
- Property values: any string, max 255 characters.
- Limits: maximum 10 custom parameters.
Ensure reliable tracking (recommended)
Add this script to your HTML <head>
to guarantee identification is captured even when triggered before the main script loads:
<script id="datafast-queue">
window.datafast = window.datafast || function() {
window.datafast.q = window.datafast.q || [];
window.datafast.q.push(arguments);
};
</script>
Example usage
useEffect(() => {
if (user && user.email) {
window?.datafast("identify", {
user_id: user.email,
name: user.name,
role: user.role,
plan: user.plan,
});
}
}, [user]);
Note: User identification is separate from custom goals. Use identify to link users to their accounts, and use custom goals to track specific user actions.
Special notes
-
Persistent tracking: You need to identify the visitor each time their cookie changes for persistent tracking. You can call
window.datafast("identify")
every time their session changes. -
Revenue attribution: If revenue attribution is present, we automatically identify the customer using data from the payment provider.