URL87
URL87

Reputation: 11022

cxApi.cxApi.getChosenVariation() only returns cxApi.NO_CHOSEN_VARIATION

I do the following - (XXXXX represent my experiment Id ) as described here - https://developers.google.com/analytics/devguides/collection/gajs/experiments#cxjs-load

<!-- Google analytics Experiment-->
        <script src="//www.google-analytics.com/cx/api.js?experiment=XXXXX"></script> 

<script>
   var variationExperiment = cxApi.chooseVariation('XXXXX');
   cxApi.setChosenVariation(variationExperiment,'XXXXX');
   console.log(variationExperiment); // gives 0 or 1 according the google decision
   console.log(cxApi.getChosenVariation('XXXXX')); // always returns -1 , mean cxApi.NO_CHOSEN_VARIATION
</script>

console.log(cxApi.getChosenVariation('XXXXX')) only return -1 even though I did cxApi.setChosenVariation(variationExperiment,'XXXXX') before .

What it is indicate ? whether my google-analytics loading didn't success ?

Upvotes: 1

Views: 909

Answers (1)

Lumpy
Lumpy

Reputation: 3652

chooseVariation doesn't allow any parameters. It uses the experiment from script load.

https://developers.google.com/analytics/devguides/collection/gajs/experiments#cxjs-choose

Upvotes: 0

Related Questions