Rich-text Reply

The Optimizely JavaScript API

hbaecklund 10-08-14
Accepted Solution

The Optimizely JavaScript API

Is there something here that's not possible using the Optimizely Javascript API?


How to "Force a visitor into a certain variation"

"The Optimizely client API provides a way for developers to modify the normal behavior of the Optimizely snippet for specific use cases. Use the API to target activation based on specific page content or events, query the state of activation, bucketing, or conversion for use in custom analytics packages, and force visitors into specific variations, among other capabilities.”


How to "set the expiration date"

window['optimizely'] = window['optimizely'] || []; window['optimizely'].push(["setCookieExpiration", 365]);


How to "add a visitor segment"

window['optimizely'] = window['optimizely'] || []; window['optimizely'].push(['addToSegment', 'apiIdentifier', 'optionalSegmentValue']);


How to "activate a google analytics integration"

// Optimizely Universal Analytics Integration

window.optimizely = window.optimizely || [];



Am I correct? All these work today with the Optimizely Javascript API?



Leanne 10-08-14

Re: The Optimizely JavaScript API

Yes this is all possible. You can find all the API details here:

Specifically, the JavaScript API is here:
Level 2