Running an experiment for visitors with certain desktop window sizes
Following the Optiverse post, I previewed audiences using screen.width < 1280 with window.innerWidth < 1280 on different monitors, both in Optimizely’s preview mode, and using the URL pattern [experiment URL]?optimizely_x[experiment ID]=1, the screen.width method worked as expected, but window.innerWidth did not. Does anyone have a suggestion on how to target an audience to a specific browser window size on a desktop monitor?
Using ?optimizely_xNNNNNNN forces the variation code to run on that specific page, regardless of audience restrictions, URL targeting, or anything else.
I created an audience with a custom JS condition of
window.innerWidth < 1280;
and pushed an experiment live using this audience. I am using a 15" MacBook Pro. When I had Google Chrome set to my full screen width, I checked my window.innerWidth in the browser console and the value was 1309. As expected, I was not included in my experiment.
I then shrunk my browser window to the left corner of my screen and checked my window.innerWidth in the browser console again. I got a value of 806. I refreshed the page, and I was included in the experiment.
Optimizely does not reload or recheck audience conditions if only the browser window size is changed. You have to refresh the page and reload the Optimizely snippet so the audience check is made again.
Could you provide the experiment ID to our Support team by filing a case here? We'll be happy to dig more deeply with you. Thanks.
Solutions Architect | Optimizely, Inc.