Rich-text Reply

Audience Custom JS Condition issue

greyvugrin 12-22-14

Audience Custom JS Condition issue

I've been trying to set up an experiment that only targets non logged in users via a custom JS condition. The code I have in place follows your "Audience conditions: Descriptions and examples". Here my setup in <head>:

<script type="text/javascript">window.logged_out = "yes";</script>
<script src="//cdn.optimizely.com/js/2098300675.js"></script>

The script above the optimizely script is only inserted if a user isn't logged in. On optimizely's end, I have an audience with the following custom JS condition:

logged_out === "yes"

The issue is that when I preview the experiment, I'm not labeled as in the audience, even though I can see logged_out being set to true in my page source code. Smiley Sad

Grey Vugrin
JDahlinANF 12-22-14
 

Re: Audience Custom JS Condition issue

The preview link forces the experiments code to run, regardless of whether you meet the audience conditions (same as when you use the "?optimizely_xNNNNNNN=1" type parameter.

Amanda 12-23-14
 

Re: Audience Custom JS Condition issue

Hey there! @nap0leon is exactly right. I recommend that you use a test cookie as a method to QA your experiment for logged in and logged out states. Using the test cookie method will allow you to start your experiment and view it live while ensuring that live traffic to your site does not get included in the experiment. 

 

You can take a look at this article for a list of suggested steps to QA your experiment: https://help.optimizely.com/hc/en-us/articles/201862554-Your-Pre-Launch-Checklist-QA-your-experiment...

 

Specifically, you can find how to set a test cookie here: https://help.optimizely.com/hc/en-us/articles/200293784-Setting-a-test-cookie-for-your-site

 

Finally -- if you do decide to use the Preview mode, please be sure to check out the "Audiences and Dimensions" tab to determine whether or not you're included in the Logged-In vs. Logged-Out audience. Check out this article here: https://help.optimizely.com/hc/en-us/articles/200039675-Preview-Mode-and-QA#segments_tab

Optimizely
bitclaw 07-31-15
 

Re: Audience Custom JS Condition issue

Wow! That's awful. The Optimizely Dev team should really put a message regarding this on the UI or at the very least in the audience documentation here: https://help.optimizely.com/hc/en-us/articles/201876450-Audience-conditions-Descriptions-and-example... or here https://help.optimizely.com/hc/en-us/articles/200040845. I just wasted two hours testing and looking in stackoverflow and googling until I got the answer here. 

Level 2
JDahlinANF 07-31-15
 

Re: Audience Custom JS Condition issue

@bitclaw Perhaps the article that discusses how to use the force parameter is what you are looking for: https://help.optimizely.com/hc/en-us/articles/200107480

 

Specifically, where it says "This method involves adding a query parameter to the end of any URL on your site which tells Optimizely which experiment and which variation to run when that page loads, regardless of the targeting conditions (both audience targeting and URL targeting)."

 

 

bitclaw 07-31-15
 

Re: Audience Custom JS Condition issue

[ Edited ]

@nap0leon What I meant was that if I hadn't come upon this article I wouldn't have known that the Audience Custom JS Condition was not working due to the experiment not being turned on. I was testing on the experiment preview. Something should either be added to the UI mentioning this in the experiment preview or at the very least in the audience documentation here: https://help.optimizely.com/hc/en-us/articles/201876450-Audience-conditions-Descriptions-and-example... or here https://help.optimizely.com/hc/en-us/articles/200040845

Level 2
JDahlinANF 07-31-15
 

Re: Audience Custom JS Condition issue

@bitclaw  I'm really confused now on what your issue was.  Your experiment was not turned on but because you were able to see it work in Preview Mode you were expecting it to be live for real users?  So you think there should be a note added to the Preview Mode help page that says that viewing the page with the preview mode URL parameters is not the same as turning on the experiment?

 

bitclaw 07-31-15
 

Re: Audience Custom JS Condition issue

[ Edited ]

@nap0leon Nope that's not it. I was previewing my experiment with it turned off. I had added an audience to the experiment with custom JavaScript. This audience was not working in preview mode. So based on this thread the workaround is what is mentioned in the previous posts.

 

In conclusion , an audience with custom JavaScript will not work in Optimezly preview mode in UI. This should be mentioned some where if this is the case. 

Level 2
Amanda 07-31-15
 

Re: Audience Custom JS Condition issue

[ Edited ]

@bitclaw - Perhaps this is the article you would have found helpful? It describes how to set the audience condition in preview mode so you can see the variation as expected. https://help.optimizely.com/hc/en-us/articles/200039675-Preview-Mode-and-Cross-Browser-Test#segments... and https://help.optimizely.com/hc/en-us/articles/200039675-Preview-Mode-and-Cross-Browser-Test#viewing_... (speficically the part about the "Viewing As" tab)

 

Does that look correct? You could also use these workaround methods as mentioned in this thread. 

 

Totally agreed that it should not be this difficult for you to find. I have sent your feedback along to our education team to additional information to make this more clear. 

Optimizely
Yeesheen 08-19-15
 

Re: Audience Custom JS Condition issue

Hi @greyvugrin and @bitclaw,

 

I'm a Customer Education Manager at Optimizely. I'm sorry to hear that you both had frustrating experiences with custom JS audiences in Preview mode. After a little investigating, we discovered that the issues you experienced are due to a bug. Currently, an experiment must be live in order for the audience conditions to be evaluated correctly in Preview mode. We've alerted our engineering team about this issue and linked them to this thread. 

 

We've also added a warning message in the Knowledge Base article on Preview Mode so that in the future, customers in this situation know to use the test cookie method instead. Thank you for bringing this to our attention. 

 

Sincerely,
Yeesheen

Optimizely