Skip to main content
ShortKit assigns every device an anonymous ID on first launch. When your user signs in, you promote them to an identified user and the backend merges their anonymous history.

Anonymous by default

On first initialization, the SDK generates a random UUID and persists it in device storage. This ID is attached to every API request and analytics event automatically. No setup required.
The anonymous ID survives app restarts. It is only replaced when you call clearUserId().

Setting an identified user

Call setUserId when the user signs in. The SDK switches all subsequent requests and events to this ID and triggers identity resolution on the backend.
You can also pass the user ID at init time to skip the anonymous-first flow entirely:

Clearing identity

Call clearUserId on sign-out. The SDK reverts to anonymous mode with a fresh UUID. The previous anonymous ID is discarded.

How identity resolution works

When setUserId is called, the SDK sends a POST /v1/identity/resolve request with both the anonymous ID and the identified user ID:
The anonymous user profile is merged into the identified user profile, the anonymous device ID is appended to the identified user’s linked_device_ids array, and the anonymous profile is deleted. All events previously attributed to the anonymous ID become queryable under the identified user.

User ID on events

Every analytics event the SDK emits carries the current user ID in the X-User-Id request header — whether the user is anonymous or identified. You never need to attach user IDs to events manually. The SDK handles this at the network layer.