Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Get Forced Variation

This topic describes the Get Forced Variation method, which returns the forced variation set by Set Forced Variation, or null if no variation was forced.

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.

ParameterTypeDescription
overrideKey
All keys inside object are also required
ExperimentOverrideKeyExperimentOverrideKey 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.

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.