0

What is the best way in Codeigniter to redirect x% of users to a beta site. For example my default site is: http://www.example.com, but I want to redirect 10% to http://www.beta.example.com. I'm looking for a solution that would also work for all paths (e.g. http://www.example.com/products/123 => http://www.beta.example.com/products/123).

user2694306
  • 3,832
  • 10
  • 47
  • 95

2 Answers2

1

Check if the user has a long term cookie which determines their target A/B site.

If the A/B cookie exists, either redirect to beta site or do nothing.

Generate a random number, 1-100.

If it is greater than X (your desired percentage) mark that user with a long term cookie of the regular site.

If it is less than or equal to X (your desired percentage) mark that user with a long term cookie of the beta site, redirect that user to beta site.

On the beta site, mark the user with a long term cookie for its subdomain.

chugadie
  • 2,786
  • 1
  • 24
  • 33
  • As ahmad said, you cannot get the percentage of users because there is not a concrete defined set of users. Using percentage of likelyhood to move user to other site is as close as anybody can get. – chugadie Mar 09 '15 at 12:56
  • People who refuse 1st party cookies *might* see a random site each time they visit. You should offer a manual link to let people choose and use JS to set a long term cookie or maybe just redirect to server side code that does the above algorithm and sets cookies. I'm not sure if JS can set cookies easier than HTTP Headers if the browser is set to reject them. – chugadie Mar 09 '15 at 13:00
0

Since you cannot get the percentage of guests users (It's always changing), You can offer a link "Try Beta" for these.

As for registered users, create a new column in users table 'on_beta' which is either 0 or 1

Get a random 10% of users using an sql query & set them on beta while allowing them to switch back to non-beta site.

ahmad
  • 2,709
  • 1
  • 23
  • 27