简体   繁体   English

cxApi.chooseVariation()始终返回0

[英]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.

相关问题 cxApi.cxApi.getChosenVariation()仅返回cxApi.NO_CHOSEN_VARIATION - cxApi.cxApi.getChosenVariation() only returns cxApi.NO_CHOSEN_VARIATION cxApi.chosenVariation()为同一位用户提供不同的值(使用Google Content Experiments JavaScript API) - cxApi.chosenVariation() gives different values fore the same user (using Google Content Experiments JavaScript API) 如果我有针对页面运行的google实验,是否可以仅通过删除chooseVariation调用来有效地暂停实验? - If I have an google experiment running against a page, can I effectively pause the experiment just by removing the chooseVariation call? 实时数据会在报告中显示吗? - will realtime data always show in reports? analytics.js 事件并不总是发送 - analytics.js event not always sent Google Analytics _trackEvent-始终是网站的根目录 - Google Analytics _trackEvent - always root of site Google Analytics:网站速度平均值始终为0.00 - Google Analytics: Site Speed average always at 0.00 Analytics-&gt; BigQuery-&gt; Tableau | 日期返回空 - Analytics -> BigQuery -> Tableau | Date Returning Null iOS上的Google Analytics在调度时返回NO,没有调试输出 - Google Analytics on iOS returning NO on dispatch, no debug output 返回用户在Google Analytics(分析)上的多次回报 - Multiple returns of Returning Users on Google Analytics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM