Rich-text Reply

Javascript API sometimes not getting variationNames

storefront 01-21-16

Javascript API sometimes not getting variationNames

I have set the activation mode of the experiment to be "manual" and in my code, I am doing this:

 

    // experimentId is a string

    window.optimizely.push(['activate', experimentId]);

    var variationName = window.optimizely.variationNamesMap[experimentId];

    if (!variationName) {

        logger.error('Experiment is not set up correctly: ', experimentId);

    }

 

We would get the error logs a few times a day. Is there a reason that this is happening?

 

Lyndsey 01-23-16
 

Re: Javascript API sometimes not getting variationNames

Thank you for reaching out to the Optimizely support team!

I've double checked this implementation on my own system, and using the manual activation more create a timing issue, where the variation name is not readily available. This has to do with the different workflow for the snippet execution on manually activated experiments. You can read more on that here:

https://help.optimizely.com/hc/en-us/articles/205014107-How-Optimizely-s-SDKs-Work-SDK-Order-of-exec...

If you'd like to confirm this and QA on your end, you can do so by duplicating the experiment and changing the duplicate to immediate activation. Then comment out the activation line in the code snippet above. The variationName variable will be defined.

What are you trying to achieve with obtaining the variation name in this manner? Perhaps there's another method that will help.
Thanks,
Lyndsey
Technical Support Engineer
Optimizely
Optimizely