Different Theme for Current URL - Using Javascript?
You couldn't select a Drupal theme through JS, unless you reloaded the entire page using JS after the initial load.

The better way to do this would be to use hook_custom_theme() to set the theme. Since you need to track the theme with Optimizely, you can send a JS variable from PHP and then pass that to Optimizely in order to track which theme is being viewed.

You could do this in hook_custom_theme() to have 50% of the users use one theme, 50% use the other:

function hook_custom_theme()
{
  $theme = variable_get('switch_custom_theme', 'theme_1');
  $new_theme = $theme == 'theme_1' ? 'theme_2' : 'theme_1';
  variable_set('switch_custom_theme', $new_theme);
  return $new_theme;
}


Then you can get the theme in JS at Drupal.settings.ajaxPageState.theme (Drupal 7). I can't help you with the Optimizely side of things as I don't use it, you'd have to look at their documentation.