[英]cxApi.chosenVariation() gives different values fore the same user (using Google Content Experiments JavaScript API)
I'm trying to create ab testing experiment using Google Content Experiments JavaScript API (according to https://developers.google.com/analytics/devguides/collection/analyticsjs/experiments ). 我正在尝试使用Google Content Experiments JavaScript API(根据https://developers.google.com/analytics/devguides/collection/analyticsjs/experiments )创建Ab测试实验。 I thought user should always see only one experiment, but chooseVariation gives me different values (0 or 1) if I refresh page.
我认为用户应该始终只能看到一个实验,但是如果刷新页面,chooseVariation会给我提供不同的值(0或1)。 It seems it always just randomly choose 0/1 and doesn't remember chosen value.
似乎总是随机选择0/1,而不记得选择的值。
What could cause this problem/behaviour? 什么会导致此问题/行为? (experiment is running)
(实验正在运行)
Here is my code (on localhost): 这是我的代码(在本地主机上):
<html>
<body>
<script src="//www.google-analytics.com/cx/api.js?experiment=HTuY9pj1SPCOkYUkMz1Tvg"></script>
<script>
var g_exp_id = "HTuY9pj1SPCOkYUkMz1Tvg";
var chosenVariation = cxApi.chooseVariation();
console.log(chosenVariation); //always gives different values (0 or 1) for the same user (after refreshing the page)
</script>
</body>
</html>
Could it be that you're not letting GA to write the cookie values? 可能是您不让GA编写Cookie值吗? That should help GA to remember the experiment variation, picked for user.
这应该有助于GA 记住为用户选择的实验变体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.