Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign running experiment to logged_in_user #711

Open
puneetpandey opened this issue Jul 17, 2023 · 1 comment
Open

Assign running experiment to logged_in_user #711

puneetpandey opened this issue Jul 17, 2023 · 1 comment
Assignees

Comments

@puneetpandey
Copy link

puneetpandey commented Jul 17, 2023

Hi,

I need help with below use-case:

  1. A/B test with 3 add to cart buttons
  2. A user / visitor (doesn't require login) can add items to their cart
  3. 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:

  1. On Cart Page: ab_finished({plan_pricing_container: "add_to_cart"}, reset: false)
  2. On Checkout: ab_finished(plan_pricing_container: "purchase", reset: false)

Use-case:

  1. Guest sees "buy_this_plan" button > Experiment starts
  2. Guest adds item to cart > Experiment successfully completed for add_to_cart goal
  3. 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):
image

It seems there few issues:

  1. I am unable to assign a running experiment to a logged_in_user (if they don't change the browser).
  2. Using both cookie_adapter and redis_adapter not working. I end up seeing conversion not getting tracked for purchase goal (screenshot above).
  3. If I remove cookie_adapter and redis_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)
Screenshot 2023-07-17 at 1 11 54 PM

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 puneetpandey changed the title Assign experiment to logged_in_user Assign running experiment to logged_in_user Jul 17, 2023
@puneetpandey
Copy link
Author

puneetpandey commented Jul 21, 2023

After checking the docs on goals here're few things I found

  1. This does not mean that a single experiment can complete more than one goal.
  2. 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:

  1. metrics
  2. combine_experiments
    I will see how it turns up. Meanwhile any help would be highly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants