如何有效使用Route53进行在线实验?

8
作为一个每月有200万+独立用户的网站产品负责人,我想进行一些A/B测试,并且可以通过Google Analytics目标跟踪,而不需要付高额费用进行在线测试服务。使用Google自己的Content Experiments需要使用JS重定向,这样我就不必冒险面临页面加载性能下降,并且可以自由地使用CE限制你的五个变化以上。

这个答案引起了我使用Route53避免Google Content Experiments的兴趣:

Google Analytics内容实验A/B测试服务器端代码无需页面刷新

我想知道如何提供和跟踪这些变化。

据我现在的理解,Route53在DNS级别上运作,并且可以将流量平衡到不同的IP地址,因此我可以将mydomain.com 50% / 50%提供给200.0.0.1和200.0.0.2。然后,我可以使用服务器端代码确定正在使用的IP并为Google Analytics提供不同的JS跟踪代码。

那么,如果用户到达或未到达我的GA目标页面,我就可以衡量我的活动效果了?

没错,吗?还是我在GA或站点设置方面遗漏了什么?

1个回答

3
如果您已经在使用Route53并且不介意分别跟踪不同的跟踪代码,那么您可以使用一些服务器端代码来选择该ID的正确跟踪代码。以下是PHP示例。
<?php
    var $serverIp_trackingCodes_map = array(
        '192.168.1.1' => 'UA-XXXXX-1',
        '192.168.1.2' => 'UA-XXXXX-2',
        '192.168.1.3' => 'UA-XXXXX-3',
        '192.168.1.4' => 'UA-XXXXX-4'
    );
?>

<script type="text/javascript">
    //The usual ga tracking code
    var _gaq = _gaq || [];
    //Pass in the tracking code for that server
    _gaq.push(['_setAccount', '<?php echo $serverIp_trackingCodes_map[ $_SERVER["SERVER_ADDR"] ] ?>']);
    _gaq.push(['_trackPageview']);

    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

</script>

但使用一个跟踪代码并设置一个自定义变量与服务器名称或IP地址可能会更容易。这可以在报告中用作筛选器。

<script type="text/javascript">
    //The usual ga tracking code
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']);
    _gaq.push(['_trackPageview']);

    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();

    //Set the custom variable
    _gaq.push(['_setCustomVar', 1, 'ServerIP','<? echo $_SERVER["SERVER_ADDR"]?>']);

</script>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接