控制何时添加虚荣 a/b 测试参与者

Controlling when participants are added with vanity a/b test

使用 vanity 进行 A/B 测试。该测试依赖于有条件地向某些用户显示的模式。根据您看到的测试的哪一侧,模态包含不同的激励措施。

模态代码在我们应用程序的多个页面上加载的部分代码中。

示例:

<%= render partial: 'modals/example' %>

该部分包含将要显示的内容的条件:

<% if ab_test(:whatever) == "something" %>
   <p>Stuff to show</p>
<% else %>
   <p>Different stuff to show</p>
<% end %>

我正在相关位置跟踪相关指标。

测试本身在显示内容和转换方面符合预期。我 运行 遇到的问题是,因为即使未显示模态,部分内容也会加载...每个登陆引用此部分内容的页面上的人都被添加为 "participant" 并且我只想把真正看过模态的人算作参与者。

我们也使用 mixpanel,我可以用它转向 运行 测试。不过,我喜欢虚荣心,如果有一个不会显着增加实施时间的合理解决方案,我更愿意使用它。希望有人能指出我所缺少的以及如何解决问题。

我会尝试通过 ajax 发送 post,其中包含在显示模式后将参与者添加到 /vanity/add_participant 所需的数据。

$('#myModal').on('shown', function(){
    $.ajax({
    type: "POST",
    url: '/vanity/add_participant',
    data: {
      participant_data: participantData
    },
    success: function(data) {}
  })
});

将以下内容添加到 application.rb:

Vanity.configure do |config|
  config.use_js = true

  # Optionally configure the add_participant route that is added with Vanity::Rails::Dashboard,
  # make sure that this action does not require authentication
  # config.add_participant_route = '/vanity/add_participant'
end

Then add <%= vanity_js %> to any page that calls an A/B test after calling ab_test. vanity_js needs to be included after your call to ab_test so that it knows which version of the experiment the participant is a member of. The helper will render nothing if the there are no ab_tests running on the current page, so adding vanity_js to the bottom of your layouts is a good option. Keep in mind that if you set use_js and don't include vanity_js in your view no participants will be recorded.

不确定这是否有帮助哈哈。