For the complete documentation index, see llms.txt. This page is also available as Markdown.

Tracking the User ID

Associate ContextSDK events with the user identifier from your own system so the same user can be matched across both platforms.

What is the user ID?

The user ID is the identifier you already use to recognise a user in your own systems. By passing it to ContextSDK, every context event is tagged with that same identifier, so you can match a user between your platform and ContextSDK.

Why track the user ID?

Sharing a common user identifier lets you join ContextSDK's analytics with your own data, making it easier to reason about a single user across both systems.

How to track the user ID

Call setUserId(_:) with the identifier of the currently signed-in user. The value is stored on the device, so it's reapplied automatically on the next app start, and it's attached to every event from that point on. The same user ID is shared across all ContextSDK products, so this single call also associates the user with your push notifications.

ContextManager.setUserId("your-user-id")

Call this again whenever the signed-in user changes to overwrite the previous value.

Clearing the user ID

Pass nil to clear a previously set user ID, for example when the user signs out. This removes the stored identifier from the device and stops attaching it to events.

ContextManager.setUserId(nil)

Last updated

Was this helpful?