Identity & Users
Identify users, manage sessions, and track across devices. Identity ties events, flags, and experiments to specific users.
Identifying Users
When a user logs in, call identify() to associate their activity with their user ID.
Client-side (via the React provider — recommended)
// The provider handles identity automatically when you pass the user prop
<GoaTechProvider
config={{ apiKey: "lp_pub_..." }}
user={{ id: user.id, traits: { email: user.email, plan: user.plan } }}
>
{children}
</GoaTechProvider>Client-side (manual)
const gt = useGoaTech();
gt.identify("user_123", { email: "alice@example.com", plan: "pro" });Server-side
gt.identify("user_123", { email: "alice@example.com", plan: "pro" });User Traits
Traits are properties attached to a user. They can be used for:
- Flag targeting — show features to users with specific traits
- Experiment segmentation — analyze results by user segment
- Analytics filtering — filter events by user properties
Common traits: email, plan, company, role, created_at, country.
Traits are merged — calling identify() with new traits adds to existing ones (does not replace all):
gt.identify("user_123", { plan: "pro" });
// Later...
gt.identify("user_123", { company: "Acme" });
// User now has both plan AND company traitsAnonymous Identity
Before identify() is called, the SDK operates in anonymous mode:
- A device_id is generated on first load and persisted to localStorage
- An anonymous_id is generated per session
- A session_id tracks the current browsing session
- All events include these IDs for attribution
After identify(), these anonymous IDs are linked to the user ID, allowing you to connect pre-login and post-login activity.
Resetting Identity
When a user logs out, call reset() to clear their identity.
Via provider (automatic)
// When user prop changes to null, the provider calls reset() automatically
<GoaTechProvider config={config} user={null}>Manual
const gt = useGoaTech();
gt.reset();reset() clears:
- User ID and traits
- Session ID (generates a new one)
- Experiment assignments (user will be re-assigned)
- Does not clear
device_id(persists across sessions)
Device Registration
On first initialization, the SDK registers the device with the Sheepit API. This happens automatically and non-blocking. The device_id is persisted in localStorage and reused across sessions.