How to implement A/B | split tests on Laravel?

The ABRouter is an open-source, developer-oriented tool for implementing managed A/B tests with high-level Laravel support.
The service providing a clear web interface to manage experiments, powerful API to run and track results of the tests in your Laravel application.
Installing via composer package for Laravel.
Please, checkout out package GitHub Repository.
Takes minutes to start your first A/B test. Additionally, we have the packages for vanilla PHP and Symfony:

PHP guide
Symfony Guide


Start for free

Image

Why do we need A/B tests?

Long story short - to improve conversions. The main advantage of AB-testing is making the right decisions.

Real world example: you have a two implementations of free trials on your website. In the first case, you require a card number to sign up, and for the second your user can proceed to the platform without the card. What is the best choice in that case?

AB test with two branches can show you the right answer. Your decision will be based on the number of completed sign-ups and the final number of the paid users in these branches.

Start for free
Image

Our first task with A/B test

Task definition
Our task is testing the most convertible color of form button. For example, your current color of sign up button is blue, but you want to check, what if the green button will be more convertible?
Goal:
to test most convertible color of form button
Branches:
red - 33%, green - 33%, blue - 33%.
Technically:
assign the color of the button: which the user got into.

Creating first A/B test on ABR side

So, there are the step to be done:
Step 1: Sign-up by the link
Step 2: Create your experiment
Pay attention to the Experiment ID. You will use it as the identifier of experiment to run it.
Step 3: Grab the data
After creating the A/B test you can to get the important data to run it.
Experiment id:

Token:

Application side | Start coding

Step 1: Install
Install the library to your codebase on PHP: https://github.com/abrouter/laravel-abtest
This library based on main ABRouter client: https://github.com/abrouter/abrouter-php-client
1
Install the package:
composer require abrouter/laravel-abtest

This package provide auto discovery for service provider. If Laravel package auto-discovery is disabled, add service providers manually in your /app/app.php of your repository.

There are service providers you must add:

\Abrouter\LaravelClient\Providers\AbrouterServiceProvider::class
2
Publish client configuration:
php artisan vendor:publish --tag=abrouter
3
Configure the client:
There you have to put your ABRouter token from your dashboard which is described in the third point.
Step 2: Code
Now we are ready to code. Also, you can check an example of fully completed code on GitHub:
https://github.com/abrouter/laravel-example
Step 3: There is our results
Color of the button will be automatically changed on each request for every page reload. Because we have used uniqid(). ABRouter system will memorize the relation between user identifier and branch he got, so if we will repeat the request with the same user identifier we will get the same branch as on previous run.

You're don't need to implement it on your own

Because we already did it in a perfect way in ABRouter open-source platform for A/B testing and feature flags!

Branch memorization & User identifiers association
ABRouter system will keep the user in the same branch after he got it the first time. It’s important to keep the user in the same branch all the time. With user identifiers association we will accept the relations between permanent user id and guest user id and keep the user in the same branch. Make an association through sending both identifiers in single statistic event.
Viewing statistics by branch
We will match the branch with the users events and show you detailed statistics which will help you to decide the better performed branch to make it base line.
Useful UI
We have implemented first-class UI to manage your A/B tests, feature flags and viewing statistics. It will help you to make the important decisions on your product and increase the your product growth.

Start tracking your A/B test

You can learn more about tracking user events in the docs. Tracking user events is important for making decisions on your experiments. After implementing the sending of events you can see the statistics by users which got into the experiment. ABRouter supports viewing the stats by the experiment and over all statistics.

Getting started is easy

Find key growth drivers with ABRouter
Create your first A/B test

Summary

I have shown you how to implement an A/B test with Laravel framework via ABRouter. Looks like it's quite simple.
Please, remember, that every change that you are making to the app should be through an A/B test. It's a key to build a successful product.

If you have any questions, feel free to ask me at abrouter@proxiedmail.com or via green "Ask Us" button here.

Image
Alex Yatsenko Senior Developer at ABRouter