How Visitor Identification Works
Every visitor gets a unique anonymous ID that persists across sessions. When users log in or provide their email, DATALYR links their anonymous ID to their user ID for cross-device tracking.Anonymous ID
What it is: A unique identifier automatically generated for every visitor (anon_abc123...).
How it’s stored:
- Primary: Root domain cookie (
__dl_visitor_id) - Backup: localStorage (
dl_anonymous_id)
- Lasts 1 year by default
- Works across subdomains (e.g., www.example.com and app.example.com)
- Survives browser restarts
- Does NOT survive browser data clearing
User ID
What it is: Your internal identifier for logged-in users (user_123, email address, database ID, etc.). How it’s set:- Stored in localStorage (
dl_user_id) - Survives page reloads and browser restarts
- Cleared on logout (call
datalyr.reset())
Distinct ID
What it is: The primary identifier DATALYR uses for each visitor. Logic:Cross-Subdomain Tracking
DATALYR automatically tracks visitors across subdomains using root domain cookies.How It Works
When a visitor first arrives at www.example.com:- DATALYR generates
anon_abc123 - Sets cookie on root domain (
.example.com) - Cookie is accessible on all subdomains
- DATALYR reads cookie from root domain
- Uses same
anon_abc123ID - Journey continues seamlessly
Supported Domains
Standard TLDs:.com,.net,.org→ Cookie set on.example.com
.co.uk,.com.au,.co.nz→ Cookie set on.example.co.uk
localhost→ Cookie set onlocalhost
192.168.1.1→ Cookie set on exact IP
Cross-Device Tracking
Link visitors across devices using user identification.Example Journey
Device 1 (Mobile):- Purchase attributed to “direct” (wrong!)
- Ad spend wasted
user_789 and attributes the purchase to the original Facebook ad.
Session Tracking
Sessions track continuous user activity with 30-minute timeout.Session ID
Format:sess_: Prefix1727634645123: Timestamp (milliseconds)a1b2c3d4: Random identifier
- Stored in localStorage (
dl_session_data) - Includes start time, last activity, page count, event count
Session Lifecycle
New Session Starts When:- First visit to site
- 30 minutes of inactivity
- Browser is closed and reopened (after timeout)
- User navigates between pages
- User is active (clicks, scrolls, etc.)
- Time since last activity is less than 30 minutes
- 30 minutes of inactivity
- User closes browser (eventually)
datalyr.reset()is called
Session Data
Each session stores:Identity Resolution
DATALYR automatically links anonymous IDs to user IDs when you callidentify().
How It Works
-
Pre-Login:
-
User Identifies (Login/Signup):
-
Post-Login:
-
Identity Link Event Sent:
-
All Past Events Linked:
- DATALYR retroactively links all
anon_abc123events touser_456 - Complete journey from anonymous → identified
- Attribution preserved across identification
- DATALYR retroactively links all
Cookie Storage
Primary Cookie
Name:__dl_visitor_id
Value: Anonymous ID (anon_...)
Attributes:
- Domain: Root domain (e.g.,
.example.com) - Path:
/ - Max-Age: 31536000 (1 year)
- SameSite:
Lax - Secure: Yes (on HTTPS sites)
localStorage Backup
DATALYR also stores IDs in localStorage as a backup: Keys:dl_anonymous_id: Anonymous IDdl_user_id: User ID (after identify)dl_session_data: Current session info
- Cookie: Works across subdomains
- localStorage: Survives when cookies are blocked or deleted
- Fallback strategy ensures tracking continues
Privacy and Compliance
Opt-Out
Users can opt out of tracking:Do Not Track
DATALYR respects browser Do Not Track (DNT) settings by default: Respected Signals:navigator.doNotTrack === '1'navigator.globalPrivacyControl === truewindow.globalPrivacyControl === true
GDPR Compliance
Clear user data on request:Troubleshooting
Visitor ID changes on every page load? Check that:- Cookies are enabled in browser
- Third-party cookie blockers are disabled
- You’re not in incognito/private mode
- Cookie domain is set correctly
- Both subdomains are on same root domain
- Cookie is set on root domain (check with DevTools)
- No cookie blockers interfering
identify()was called with a non-empty userId- localStorage is available (not disabled)
reset()wasn’t called unintentionally
- Cookies were cleared by user
- Cookie didn’t save properly (check domain)
- localStorage also cleared
Next Steps
Identity Calls
Learn how to identify users
Events Overview
Understand event tracking
Cross-Domain Tracking
Track across multiple domains
Attribution Models
How attribution works