Skip to main content

Custom Assignments

Warning

Events with custom assignments are counted as eligible events by the ABsmartly statistics engines. If you are using these methods for development purposes (to force a particular variant for yourself or somebody else on the team) it is likely that you need the context.override methods instead.

Sometimes it may be necessary to override the automatic selection of a variant. For example, if you wish to have your variant chosen based on data from an API call. This can be accomplished using the context.customAssignment() method.

const chosenVariant = 1;

context.customAssignment("experiment_name", chosenVariant);

If you are running multiple experiments and need to choose different custom assignments for each one, you can do so using the customAssignments method.

const assignments = {
experiment_name: 1,
another_experiment_name: 0,
a_third_experiment_name: 2,
};

context.customAssignments(assignments);
info

These methods can be called before or after the context is ready.