[英]cxApi.chooseVariation() always returning 0
My site is a single page webapp. 我的网站是单页webapp。 I'm loading the experiment code with my experiment id:
我正在使用我的实验ID加载实验代码:
<script src="//www.google-analytics.com/cx/api.js?experiment={@ js_settings.analytics.experimentid @}"></script>
After all is loaded, at the moment I display the page, I select the right template by calling a function which does the following: 加载完毕后,在我显示页面的那一刻,我通过调用执行以下操作的函数选择正确的模板:
ga('set', 'expId', experiment_id);
var variation = cxApi.getChosenVariation(experiment_id) || cxApi.chooseVariation();
cxApi.setChosenVariation(variation, experiment_id);
ga('set', 'expVar', variation);
ga('set', 'dimension1', variation);
ga('send', 'pageview');
Now, it seems like cxApi.chooseVariation()
always returns 0. 100% of the 205 sessions so far were given the default variation (0). 现在,似乎
cxApi.chooseVariation()
始终返回0.到目前为止,205个会话中的100%被赋予默认变体(0)。 Why? 为什么?
The problem seems to have been that the experiment javascript code is required to be present on the page even if you manually use cxApi. 问题似乎是即使您手动使用cxApi,也需要在页面上显示实验javascript代码。 You have to modify the code such that it doesn't redirect the user and then you can call chooseVariation() and it will return an actual variation, instead of always 0.
您必须修改代码,使其不重定向用户,然后您可以调用chooseVariation(),它将返回实际变体,而不是始终为0。
Surely this API should be improved because in its current state it's mediocre at best. 当然,这个API应该得到改进,因为在目前的状态下它最多也是平庸的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.