Reputation: 11022
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
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