Assign running experiment to logged_in_user
puneetpandey opened this issue · 1 comments
puneetpandey commented
Hi,
I need help with below use-case:
- A/B test with 3 add to cart buttons
- A user / visitor (doesn't require login) can add items to their cart
- They need to be logged-in/signup for checkout (checkout requires
current_user
object)
My Setup:
# A/B test: Split gem setting starts here
cookie_adapter = Split::Persistence::CookieAdapter
redis_adapter = Split::Persistence::RedisAdapter.with_config(
lookup_by: -> (context) { context.send(:current_user).try(:id) },
expire_seconds: 2592000
)
Split.configure do |config|
config.redis = 'redis://localhost:6379'
config.persistence = Split::Persistence::DualAdapter.with_config(
logged_in: -> (context) { !context.send(:current_user).try(:id).nil? },
logged_in_adapter: redis_adapter,
logged_out_adapter: cookie_adapter
)
config.persistence_cookie_length = 7.days.to_i
config.experiments = {
plan_pricing_container: {
alternatives: [
{
name: "original",
percent: 50,
metadata: {
"original": {"text": "The original plan pricing container"}
}
},
{
name: "buy_this_plan",
percent: 25,
metadata: {
"buy_this_plan": {"text": "Button with text Buy this plan"}
}
},
{
name: "purchase_options",
percent: 25,
metadata: {
"purchase_options": {"text": "Button with text Purchase options"}
}
}
],
goals: ["add_to_cart", "purchase"]
}
}
config.allow_multiple_experiments = true
end
# A/B test: Split gem setting ends here
The way I am calling conversions for the goals:
- On Cart Page:
ab_finished({plan_pricing_container: "add_to_cart"}, reset: false)
- On Checkout:
ab_finished(plan_pricing_container: "purchase", reset: false)
Use-case:
- Guest sees "buy_this_plan" button > Experiment starts
- Guest adds item to cart > Experiment successfully completed for add_to_cart goal
- Guest logs-in now and completed the checkout
Expected behaviour
I should see "completed" for both add_to_cart and purchase goals.
Actual behaviour
I see this (nothing happens):
It seems there few issues:
- I am unable to assign a running experiment to a
logged_in_user
(if they don't change the browser). - Using both
cookie_adapter
andredis_adapter
not working. I end up seeing conversion not getting tracked forpurchase
goal (screenshot above). - If I remove
cookie_adapter
andredis_adapter
blocks and repeat the same steps then after checkout I see -ve events (see below). (Note: add_to_cart worked fine but purchase resulted in this)

The traffic on my website is on the higher side, so I found and decided to go for CookieAdapter
and use Redis Adapter only for logged_in_user/s
.
Please suggest!
% bundle info split
* split (4.0.2)
Summary: Rack based split testing framework
Homepage: https://github.com/splitrb/split
Source Code: https://github.com/splitrb/split
Wiki: https://github.com/splitrb/split/wiki
Changelog: https://github.com/splitrb/split/blob/main/CHANGELOG.md
Bug Tracker: https://github.com/splitrb/split/issues
Mailing List: https://groups.google.com/d/forum/split-ruby
Path: /.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/split-4.0.2
puneetpandey commented
After checking the docs on goals
here're few things I found
- This does not mean that a single experiment can complete more than one goal.
- Once you finish one of the goals, the test is considered to be completed, and finishing the other goal will no longer register
This clearly means what I am trying to do is technically wrong. Now I am left with 2 options:
- metrics
- combine_experiments
I will see how it turns up. Meanwhile any help would be highly appreciated.