我有以下脚本:
<script src="//www.google-analytics.com/cx/api.js?experiment=XXXXXXXXXXXXXXXXXXXXXXX"></script>
<script>
// Determine the current chosen variation
console.log( cxApi.getChosenVariation() ); // returns -1 (equivalent to cxApi.NO_CHOSEN_VARIATION)
// Tell Google to choose a variation for me
var variation = cxApi.chooseVariation();
console.log( variation ); // returns 0 <-- original variation
// Determine current chosen variation again
console.log( cxApi.getChosenVariation() ); // returns -1 again... why?
// Lets force a chosen variation:
variation = cxApi.setChosenVariation(1);
// And determine the chosen variation one more time:
console.log( variation ); // returns 1, as expected
</script>
那么这里发生了什么?似乎使用chooseVariation()
无效。谷歌没有为我选择变种。它返回零,但后来它说没有选择变化。只有当我自己选择变体时,一切似乎都有效。