Search code examples
angularjsoptimizely

How can I get the active experiment/variant name in optimizely?


I try to integrate Optimizely with AngularJS and I want to show different templates based on what variation is running. I would add a constant function to the Angular app, that would check if a variant/variants are active.

sth like

function isVariant(variantNames) {
   return true; // if any of the variants are active.
}

I could not find in the Optimizely documentation on how to get this data.


Solution

  • You can check which experiments are active with

    optimizely.activeExperiments
    

    To get the variation in which you are bucketed you can use

    optimizely.variationNamesMap
    

    Chris