How Anonymous Tracking Works
First Visit — Anonymous ID Generated
When the SDK initializes for the first time, it generates a unique
anonymousId (for example, anon_xyz789abc123) and stores it in localStorage under the key _tappd_anonymous_id. All events from this point forward are tracked against that ID.Anonymous Events Are Captured
Every
track() and trackPageView() call is recorded with the anonymousId. You don’t need to do anything special — it all happens behind the scenes.User Identifies — Events Are Merged
When the user logs in or signs up, call
identify(). The SDK automatically links all previous anonymous events to the newly identified user.Anonymous ID Persistence
The anonymous ID is designed to survive normal browser activity, but it resets when users explicitly clear their data.Persists across...
- Browser sessions
- Tab refreshes
- Browser restarts
- Device reboots (same browser)
Resets when...
- User clears browser data
- User closes an incognito/private window
- You call
tappd.reset()
Use Cases
- E-commerce
- SaaS
Capture product browsing and cart activity before a user creates an account, then attribute that behavior to the new user automatically.
Getting the Anonymous ID
Resetting Anonymous Tracking
Calltappd.reset() when a user logs out. This clears the current identity, regenerates a fresh anonymousId, and ensures the next user on the same browser starts with a clean slate.
Data Privacy
Anonymous tracking is built with privacy compliance in mind:- No personal information is stored in the
anonymousId - Fully GDPR compliant
- Users can opt out via standard browser privacy settings
- Anonymous data can be deleted on request
Troubleshooting
Anonymous ID changes on every page load
Anonymous ID changes on every page load
Cause: The browser has
localStorage disabled or blocked.Fix: Check for localStorage support before initializing the SDK:Anonymous events are not appearing after identification
Anonymous events are not appearing after identification
Cause:
identify() was called without a valid external_id, or the anonymous context was lost before identification.Fix: Always pass a non-empty external_id when calling identify(). The SDK uses this to link the anonymous session to the user record server-side.