我执行以下操作-(XXXXX
代表我的实验ID),如此处所述-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'))
,-1
也只返回cxApi.setChosenVariation(variationExperiment,'XXXXX')
。这说明什么?我的google-analytics加载是否失败?
最佳答案
choiceVariation不允许使用任何参数。它使用脚本加载中的实验。
https://developers.google.com/analytics/devguides/collection/gajs/experiments#cxjs-choose
关于google-analytics - cxApi.cxApi.getChosenVariation()仅返回cxApi.NO_CHOSEN_VARIATION,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31984290/