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.


SDK v1.0 and higher


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.


This table lists the required parameters for the GO SDK.




All keys inside object are also required


ExperimentOverrideKey contains,

  • ExperimentKey (string): The key of the experiment to set with the forced variation.
  • UserID (string): The ID of the user to force into the variation.


(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


Creating a client with Forced Variation service:

overrideStore := decision.NewMapExperimentOverridesStore()
client, err := optimizelyFactory.Client(

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.

Did this page help you?