Rich-text Reply

Conditional Activation, not activating

juliofarfan 04-01-15
Accepted Solution

Conditional Activation, not activating

Im trying to make a conditional activation with the next code but its not activating experiment even if conditions are met. What's wrong here?

 

 

 

function(activate, options) {
for (var i = 0; i < 27; i++) {

if($("#element "+[i]+"_ place").is(':checked'))
{
activate();
}

}
}

Ehsan 04-02-15
 

Re: Conditional Activation, not activating

Hi Julio,

 

Great question!  Conditional activation requires a boolean true to be returned in order to activate.  Can you paste the the code into the console of the browser to see if it returns "true"?  If you can get it to return true there, is should also activate the experiment.

 

Check out this article titled Conditional Activation for more details.

 

If that still doesn't do it, please file a support optimizely.com/support along with the experiment ID.

 

Best,

Ehsan

Optimizely

Re: Conditional Activation, not activating

[ Edited ]

Hey Juliofarfan,

 

EDIT: I missed the syntax for conditional activation. Removing prev. explanation regarding naming function / or wrapping in IIFE. Thanks to Tom for providing answer/documentation.

 

 

-- Sean
UI Developer @ Blue Acorn

optimizely developer certification
tomfuertes 04-03-15
 

Re: Conditional Activation, not activating

Hi Juliofarfan,

 

The conditional activation syntax is actually correct - you don't need to name your function of wrap it in an iife given the way optiizely evaluates. What you're actually listening for is the checked event of a series of LI's *later on*. Given conditional activation when it's a function runs only *once*, you either need to rewrite it as a statement so it polls ala:

 

!!$('#element li:lt(27) place').is(':checked'); // evaluates to true/false every 50ms

 

OR write it as a function by binding a click listener to the documentL

 

function(activate, options) {

  $(document).bind('#element li:lt(27) place', 'change.expX', activate);

}

____
- Tom Fuertes | CTO @ CROmetrics / LinkedIn
"Most Impactful Use of Personalization" and "Experience of the Year" Optie award winner.


tomfuertes 04-03-15
 

Re: Conditional Activation, not activating

Friendly update to include conditional activation documentation: https://help.optimizely.com/hc/en-us/articles/200040225-Activation-Mode-Activating-an-experiment-dyn...
____
- Tom Fuertes | CTO @ CROmetrics / LinkedIn
"Most Impactful Use of Personalization" and "Experience of the Year" Optie award winner.