Get Forced Variation
Returns (string, bool), representing the current forced variation for the argument experiment key and user ID. If no variation was previously set, returns "", false. Otherwise, returns the previously set variation key as the first return value, and true as the second return value.
Version
SDK v1.0 and higher
Description
Forced bucketing variations take precedence over whitelisted variations, variations saved in a User Profile Service (if one exists), and the normal bucketed variation. Variations are overwritten when Set Variation is invoked.
Parameters
This table lists the required parameters for the GO SDK.
Parameter | Type | Description |
---|---|---|
overrideKey | ExperimentOverrideKey | ExperimentOverrideKey contains,
|
Returns
(string, bool)
- The key of the currently set forced variation for the argument user and experiment, or an empty string if no forced variation is currently set
- true if a forced variation is currently set for the argument user and experiment, false otherwise
Example
Creating a client with Forced Variation service:
overrideStore := decision.NewMapExperimentOverridesStore()
client, err := optimizelyFactory.Client(
client.WithExperimentOverrides(overrideStore),
)
Using Forced Variation service Get Variation:
overrideKey := decision.ExperimentOverrideKey{ExperimentKey: "test_experiment", UserID: "test_user"}
variation, success := overrideStore.GetVariation(overrideKey)
See also
Set Variation
Remove Variation
Source files
The language/platform source files containing the implementation for Go is client.go.
Updated about 1 year ago