在Rails中进行AB测试

使用Split来实施AB测试。

安装Redis
$ brew install redis

启动Redis服务器: $ redis-server

使用Bundler安装Split:
在Gemfile中添加gem ‘split’, require: ‘split/dashboard’,然后运行bundle install。

如果没有启动,会出现这个错误,请注意。
Redis::CannotConnectError (无法连接到本地主机的Redis服务器:6379 (Errno::ECONNREFUSED))。

在routes.rb文件中,添加以下内容:
mount Split::Dashboard, :at => ‘split’

将testA或testB显示在视图中,每次加载时都会显示。
index.html.erb
<% ab_test(‘test_name’, ‘testA’, ‘testB’) do |text| %>
<%= text %>
<% end %>

在测量转化率的部分,写下以下内容:
<% 结束(“创建用户”) %>

你可以通过localhost:3000/split来查看转化情况。