User Context
The user context is a crucial component in VWO's Feature Management and Experimentation SDK. It provides information about the current user, which is used for targeting and segmentation.
Usage
When calling methods like GetFlag()
, you need to provide a user context:
userContext := map[string]interface{}{
"userId": "user123",
"customVariables": map[string]interface{}{
"age": 25,
"country": "US",
},
"userAgent": "Mozilla/5.0...",
"ipAddress": "127.0.0.1",
}
flag, err := instance.GetFlag("feature_key", userContext)
if err != nil {
// Handle error
}
Paramter | Type | Description |
---|---|---|
userId 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 | map[string]interface{} | 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. |
The userId is required for all SDK calls. Other properties are optional but can be used for more precise targeting and segmentation.
Updated 3 months ago
What’s Next