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>:
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.
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.
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
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.
@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)."
@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
@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 - 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.
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.