Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.42 KB

README.md

File metadata and controls

46 lines (36 loc) · 1.42 KB

Optimizely JSClient Manager

A proof-of-concept solution for using Optimizely's Fullstack JavaScript SDK in the browser which handles SDK script loading & datafile fetching. The optlyClientManager provides wrapper functions for all of the Optimizely SDK's core methods.


Enhancements

init

Loads the SDK script and the datafile, returns a Promise. Also dispatches any tracking calls that were called pre-init.

optlyClientManager.init()

user

Set the user's UUID and attributes. These values will automatically be sent to Optimizely when calling all wrapper methods.

optlyClientManager.user('userId', {'tier': 'gold'});

Wrapper Methods

Calling these methods will automatically attach the UUID and attributes set via optlyClientManager.user

track

(This can be called prior to init)

optlyClientManager.track('add_to_cart');

activate & variation

Wrapper functions for Optimizely SDK methods activate and getVariation. The activate and variation method must be called after optlyClientManager has initallized.

optlyClientManager.activate('exp_for_b');
optlyClientManager.variation('exp_for_b');

Example:

optlyClientManager.user('userId', {'tier': 'gold', 'flag': 'B'});
optlyClientManager.track('add_to_cart');
optlyClientManager.init().then(function() {
  // activate and variation can be used here
});