Looking to hire Laravel developers? Try LaraJobs

laravel-ab-testing maintained by explicitdev

Description
Run Laravel-native A/B tests with sticky assignment, conversion tracking, and result summaries.
Last update
2026/05/09 19:21 (dev-main)
License
Links
Downloads
2

Comments
comments powered by Disqus

Laravel A/B Testing

Pipeline Status License: MIT Laravel

Laravel-native experimentation for apps that need more than feature flags.

Laravel A/B Testing is a Laravel-native experimentation package for teams that want more than feature flags. It is designed to help you define experiments as code, assign sticky variants to real Laravel subjects, track conversions, and review trustworthy results without bolting a generic external platform onto your app.

composer require explicitdev/laravel-ab-testing
php artisan vendor:publish --tag=ab-testing-config
php artisan migrate

Features

  • Experiments defined in PHP or config
  • Sticky variant assignment for Eloquent models and custom subject keys
  • Even and weighted traffic splits
  • Primary and secondary goals
  • Conversion tracking with deduplication
  • Targeting rules
  • Experiment lifecycle states: draft, running, paused, concluded
  • Result summaries with frequentist significance reporting
  • Blade directives, events, and Artisan commands
  • A full automated test suite with 100% source coverage

Quick Example

Define an experiment in a service provider:

use ExplicitDev\AbTesting\Facades\AB;

AB::experiment('checkout_cta')
    ->description('Compare checkout button copy for paid plan users.')
    ->variants(['pay-now', 'complete-order'])
    ->labels([
        'pay-now' => 'Pay Now',
        'complete-order' => 'Complete Order',
    ])
    ->goal('checkout_completed')
    ->splitEvenly()
    ->targeting(fn ($user) => $user->plan === 'paid');

Assign a variant in your application:

$variant = AB::for($user)->variant('checkout_cta');

if ($variant->is('pay-now')) {
    $buttonText = 'Pay Now';
} else {
    $buttonText = 'Complete Order';
}

Track a conversion when the goal happens:

AB::for($user)->convert('checkout_cta');

Inspect results:

$results = AB::results('checkout_cta');

Why This Package Exists

Laravel Pennant is excellent for feature flags and controlled rollouts, but it is not a full experiment system. A real experiment package needs:

  • sticky assignment
  • goal tracking
  • conversion deduplication
  • experiment lifecycle controls
  • result summaries with clear statistical framing
  • Laravel-native ergonomics across Blade, Eloquent, events, queues, and Artisan

The package focuses on self-hosted experimentation workflows for Laravel teams.

Current Non-Goals

The package does not try to solve every experimentation problem:

  • Bayesian reporting
  • sequential testing
  • multivariate testing
  • automatic guest-to-user merge
  • full funnel definitions
  • hosted SaaS control plane
  • drag-and-drop experiment builder

Those can come later without complicating the core package.

Documentation

Start with the documentation index:

Commercial Add-Ons

The MIT core covers the fundamentals. Paid add-ons can focus on business visibility and operator workflows:

  • Filament dashboard
  • experiment management UI
  • segment analysis
  • exports and reports
  • advanced statistics
  • alerting and audit trails

Commercial add-ons are sold through Explicit Development at https://explicitdev.com/packages.

Support

Open bugs, install questions, documentation gaps, and feature requests in:

Testing The Package

composer test
composer analyse
composer format:test
composer test:coverage

Contributing

Please read CONTRIBUTING.md before opening an issue or merge request.

Security

Please review SECURITY.md for supported versions and vulnerability reporting.

Guiding Principle

The package aims to stay easier, clearer, and more Laravel-native than wiring a generic experimentation tool into a Laravel app.

License

Laravel A/B Testing is open-sourced software licensed under the MIT license.