To create your own StableID for server-side experiments, follow these steps:
1. Generate a unique identifier on your server. This could be a UUID or any other form of unique ID that you prefer.
2. Store this ID in a cookie. You'll have access to this for future requests from the same device, and your client app can use this identifier as well
3. For every request, lookup this cookie value. Do steps (1) and (2) if it does not already exist.
4. Get that ID from the cookie, and set it as the customID on the StatsigUser object, so all event data and exposure checks tie back to the same user.
const userObj = { customIDs: { stableID: '<generated in your code or passed via cookie or via db lookup>' } }
If you want to use this identifier on the client side and override the auto generated stableID
, you need to read the cookie value you set in (2), and override the stableID on the client SDK.
- Override the stableID
in the client SDK by getting the value from the cookie and setting the overrideStableID
parameter in StatsigOptions.
If you are using a server SDK to bootstrap your client sdk:
- Set the stableID
field on the StatsigUser object in the customIDs map when generating the initialize response from the SDK.