user2694306
user2694306

Reputation: 4050

Redirect x% of users in Codeigniter

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).

Upvotes: 0

Views: 60

Answers (2)

chugadie
chugadie

Reputation: 2873

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.

Upvotes: 1

ahmad
ahmad

Reputation: 2729

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.

Upvotes: 0

Related Questions