首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >的多个实验

的多个实验
EN

Stack Overflow用户
提问于 2014-07-16 09:01:47
回答 3查看 2K关注 0票数 12

我们使用analytics下载实验和变体,并在我们的终端为我们的访问者做变体选择(即服务器端实验,如下所述:https://developers.google.com/analytics/solutions/experiments-server-side)

当访问者访问正在实验中的url并且有一个选定的变体时,他们会得到如下所述的javascript:

代码语言:javascript
复制
<script>
cxApi.setChosenVariation(1, 'a9BcDEFgHijKl8mON-Opqw');
</script>

这很好用。我们希望有多个实验运行(例如,一个涉及菜单的网站范围的实验,和一个特定页面的实验),变体选择和所有的一切都在我们的末端很好地工作。对于用户来说,当他们是多个实验的一部分时,他们会得到setChosenVariation的多个调用,如下所示:

代码语言:javascript
复制
<script>
cxApi.setChosenVariation(1, 'a1BcDEFgHijKl2mON-3pqr');
cxApi.setChosenVariation(1, 'z9YxWVVuTsrPl8oNM-7lkj');
</script>

我找不到任何不应该这样做的理由,但是在实验的结果中,当这种情况发生时,我们看到所有的用户只被分配给一个实验,尽管这两个实验都有结果(创建转换率>100%)。

对这种行为有何解释(我觉得第二个电话可能压倒了第一个电话?)和/或一个正确的方法来做这件事?

非常感谢

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-02-14 16:24:04

轻松的回答对我没有用。多亏了Google Analytics Debugger扩展,我可以看到这两个ga('send','pageview')都在发送关于第二个实验的数据。使用synchronous call起了作用,最后我得到了这样的结果:

代码语言:javascript
复制
var sendExperiment = function(tracker, experimentVar, experimentId) {
  cxApi.setChosenVariation(experimentVar, experimentId);
  tracker.send('event', 'experiment', 'view',{'nonInteraction': 1});
}

ga(function(tracker) {
 sendExperiment(tracker, 1, 'a1BcDEFgHijKl2mON-3pqr');
 sendExperiment(tracker, 2, 'z9YxWVVuTsrPl8oNM-7lkj');
});
票数 6
EN

Stack Overflow用户

发布于 2014-07-23 03:01:43

我认为当你在每个实验下设置一个选择的变体时,你应该把实验值发送到Google。代码如下:

代码语言:javascript
复制
cxApi.setChosenVariation(1, 'a1BcDEFgHijKl2mON-3pqr'); 
ga('send', 'pageview');
cxApi.setChosenVariation(1, 'z9YxWVVuTsrPl8oNM-7lkj'); 
ga('send', 'pageview');
票数 1
EN

Stack Overflow用户

发布于 2016-06-09 05:41:19

我意识到这是一个老生常谈的问题,但最近我不得不想出一个解决这个问题的办法,我想我会和一些现实世界的约束分享我的方法。

在高层次上,我的方法的工作方式如下:

  1. 加载Google内容实验API代码
  2. 设置分析,并创建第二个跟踪器(为同一配置文件),将只用于跟踪我正在运行的第二个并行实验。
  3. 做任何定制我的常规GA代码。
  4. 创建一个函数来检查用户当前所在的页面是否是我正在运行给定测试的页面,如果是的话,请为该特定实验的用户找到所选的变体,执行该函数并将信息发送回相关的GA跟踪器,其中包含一个自定义事件。

不幸的是,我不得不将这种方法作为我正在使用的平台,只允许我对全局标题进行编辑,而不是对任何特定页面的基础进行编辑。因此,正如我提到的,它只是检查规范的URL标记和我正在运行测试的URL。

代码语言:javascript
复制
<!-- Load the regular Content Experiments JS API without any ID parameters -->
<script src="//www.google-analytics.com/cx/api.js"></script>

<!-- Setup Google Analytics -->
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  // Create the first regular tracker like you normaly would
  ga('create', 'UA-XXXXXXXX-1', 'auto', {'allowLinker': true, 'siteSpeedSampleRate': 90});
  // Create the second named tracker just for experiments
  ga('create', 'UA-XXXXXXXX-1', 'auto', 'experimentTracker');

  //Setup all of the regular customizations for the regular tracker if you need to
  ga('require', 'linker');
  ga('require', 'linkid', 'linkid.js');
  ga('require', 'ec');
  ga('require', 'displayfeatures');
  ga('linker:autoLink', ['example.com','domain2.com'], false, true);

  // Send the pageview like normal for the regular tracker
  ga('send', 'pageview');
</script>

<script>
  // Define the different experiments you wish to run and the page
	var experimentOneID = "a1BcDEFgHijKl2mON-3pqr";
	var	experimentTwoID = "z9YxWVVuTsrPl8oNM-7lkj";
	var experimentOneURL = "http://www.example.com/experiment-1/";
	var experimentTwoURL = "http://www.example.com/experiment-2/";

  var runContentExperiment = function(experimentID) {
    // Ask Google Analytics which variation to show the user and specify the experiment ID.
    var chosenVariation = cxApi.chooseVariation(experimentID);
    // Set the chosen variation for GA
    cxApi.setChosenVariation(chosenVariation, experimentID);

    // Here is where we have the page specific code changes you might want to make
    if (experimentID === experimentOneID) {
      var pageVariations = [
        function() {},  // Original: Do nothing. This will render the default HTML.
        function() {    // Variation 1 of Experiment 1
          // Do Something here in experiment 1
        }
      ];
      pageVariations[chosenVariation]
      ga('send', 'event', 'Content Experiment', 'View', experimentID, { 'nonInteraction': 1 });
    }
    else if (experimentID === experimentTwoID) {
      var pageVariations = [
        function() {},  // Original: Do nothing. This will render the default HTML.
        function() {    // Variation 1 of Experiment 2
          // Do Something here in experiment 2
        },
        function() { // Variation 2 of Experiment 2

        }
      ];
      pageVariations[chosenVariation]
      ga('experimentTracker.send', 'event', 'Content Experiment', 'View', experimentID, { 'nonInteraction': 1 });
    }
  }

  // Check the canonical URL of the page and make sure it matches the one we want
  var canonical = document.querySelector("link[rel='canonical']").href;
  if (canonical === experimentOneURL) {
    $(function() {
      runContentExperiment(experimentOneID);
    });
  } 
  else if (canonical === experimentTwoURL) {
    $(function() {
      runContentExperiment(experimentTwoID);
    });
  } 
</script>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24776547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档