User Context
To pass additional information about the current user (including a mandatory User ID), you must create a VWOContext Object and use the available functions to set different properties onto this userContext object.
The userContext object must be passed as an argument whenever you call the getFlag() or trackEvent() functions.
userContext Properties
Parameter | 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 . |
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
import com.vwo.models.user.VWOContext
// Create VWOContext
userContext = VWOContext()
// Mandatory
userContext.id = "unique_user_id"
// Optional - if rules have pre-segmentation applied
userContext.customVariables = mutableMapOf(
"variable1" to "value1",
"variable2" to 10
)
import com.vwo.models.user.VWOContext
// Create VWOContext
val userContext = new VWOContext();
// Mandatory
userContext.setId("unique_user_id");
// Optional - if rules have pre-segmentation applied
Map<String, Object> customVariables = new HashMap<>();
customVariables.put("variable1", "value1");
customVariables.put("variable2", 10);
userContext.setCustomVariables(customVariables);
Updated 3 months ago