Download the PHP package tixelrocks/abtest without Composer
On this page you can find all versions of the php package tixelrocks/abtest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tixelrocks/abtest
More information about tixelrocks/abtest
Files in tixelrocks/abtest
Package abtest
Short Description A very simple A/B testing implementation for Laravel
License MIT
Homepage https://github.com/TixelRocks/abtest
Informations about the package abtest
Simple A/B testing
A very simple web A/B testing package for Laravel
Installation
You can use Composer to install this package easily:
Configuration
Configure your A/B experiments in config/ab.php
file (not provided by default).
Let's say we have a button somewhere on our website and we want to see what's a better
call to action (text inside the button) - "Continue" or "Finish":
Picking the variant
Some users will see "Continue" (A version or "control" version), some will see "Finish" (B variant or "treatment" variant),
this will be decided on a per-user basis, roughly at a 1:1 ratio based on a cookie that's set during
the first visit by the Tixel\AbTest\SetAbTestCookie
middleware that you can add to any
route or all routes:
For easy local troubleshooting, you can also use a query parameter at any time:
Usage in templates
Locate the button in your Blade template, and replace the button text with our helper function or our Blade directive, passing the name of the A/B experiment from the config file:
Good! The text will now display as variant A and variant B depending on the user and the cookie in the browser, but we need to track the results. This package currently ships with Google Analytics and Segment components, but it's easy to add anything else.
Let's say we want to send an event to Google Analytics:
Of course, this can be two separate DOM elements:
We can add a global click handler that will send this to GA, from any button on any page:
Okay, now we have data about how many users clicked on each variant - A or B, but to accurately calculate conversion rates, it would be nice to see how many users SAW the variants A and B, so let's send page view data as well:
Result
Now it's easy to see how many users are seeing each version and how many are clicking. In a few weeks you can decide which option keep and which one to remove :)
Managing tests
To see what's currently active, you can run a console command shipped with this package that will find all uses of abTest() function in the templates:
You can expose this as a route as well:
To disable a test, either replace the abTest()
function or @abTest
directive
with plain-text or comment out one of the options in the config file.