Single page app challenges
I have not seen much around optimizely running in a single page app with screens that are not even loaded at runtime.
For quite awhile it severely limited our ability to use optimizely. However after a late night recently I found a rather elegant solution.
First some background. Our app (https://Speek.com) has a series of views which comprise a 'page' which are all dynamically loaded and constructed on demand.
Our solution was to broadcast an event to Optimizely's version of jQuery that contained a reference to the view we were constructing. We broadcast a onBeforeRender event and an onAfterRender event. Each event contains a reference to the class itself. With these interception points in place we are now able to use basic jQuery (in optimizely) to adjust markup and even entire behaviors on a view level without any runtime concerns.
This has opened up a world of possibilities for us and hasn't come at any real cost, just a few lines in a base class.
What's also nice is we no longer have to be concerned with targeting, we simply tie it to view construction universally.
There are several implementations of this, some simple ready-to-use ones are:
https://gist.github.com/cowboy/661855 (or https://github.com/cowboy/jquery-tiny-pubsub)
@tobyurff your link is kinda wrong, the ")," is included by mistake