Rich-text Reply

How to get the current variation the user should see with API in a single page app

seb-dev 09-07-16
Accepted Solution

How to get the current variation the user should see with API in a single page app

Hello,

 

I am exploring the possibility of adding optimizely to our angular single page app. What I am trying to achieve is the following:

 

  1. Be able to run a test after a state change. Currently, I am activating the test using the manual activation code.
  2. Get the information (from Optimizely) about which variation the current visitor should see.
  3. Show the variation to the user.

 

Currently, I am having trouble finding which variation the current visitor should see. I want to use Optimizely's random allocation of traffic to know which variation I should show and then change the page accordingly.

 

The app uses:

  • AngularJS 1.5
  • UI-router

 

Level 1

CouchPsycho 09-07-16
 

Re: How to get the current variation the user should see with API in a single page app

[ Edited ]

Hi,

 

have you tried accessing:

 

optimizely.variationMap

 

via JavaScript?

 

"This is a hash table whose keys are the experiment ids of experiments running for the visitor (including inactive experiments for which the user has been bucketed), and whose values are the variation indexes for those experiments." ( see: http://developers.optimizely.com/javascript/reference/ )

 

Kind regards

 

Michael

 

 




"the essence of the creative act is to see the familiar as strange." (anonymous)