User Context
The userContext object must be passed as an argument whenever you call the getFlag() or trackEvent() functions.
userContext Properties
Paramter | Type | Description |
---|---|---|
id Required | String | Unique user ID for the current user. 'id' is the only required property in userContext. This ID should be a unique identifier for the current user which you need to pass to VWO. Read more here . |
userAgent Optional | String | The userAgent object for the current user, can be used for targeting & segmentation. |
ipAddress Optional | String | IP Address of the current user, can be used for targeting & segmentation. |
customVariables Optional | Object | Any additional details of the current user that you want to push to VWO can be added here as key-value pairs, can be used for targeting & pre-segmentation. |
Usage
const userContext = {
id: 'user-id',
userAgent: '',
ipAddress: '',
customVariables: {
plan: 'free'
}
}
// userContext to be passed as an argument with the following function calls:
const featureFlag1 = await vwoClient.getFlag('feature_key', userContext);
vwoClient.trackEvent('event-name', userContext);
vwoClient.setAttribute('attribute-name', 'attribute-value', userContext);
Updated 3 months ago
What’s Next