PHPackages                             pivotalso/pivotal-ab - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. pivotalso/pivotal-ab

ActiveLibrary[Framework](/categories/framework)

pivotalso/pivotal-ab
====================

Blade A/B testing for Laravel

1.1.2(1y ago)322[4 PRs](https://github.com/pivotalso/pivotal-ab/pulls)proprietaryPHPPHP ^8.1CI passing

Since Apr 4Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/pivotalso/pivotal-ab)[ Packagist](https://packagist.org/packages/pivotalso/pivotal-ab)[ Docs](https://github.com/pivotalso/laravel-ab)[ RSS](/packages/pivotalso-pivotal-ab/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (11)Versions (11)Used By (0)

Laravel AB by Pivotal
=====================

[](#laravel-ab-by-pivotal)

Currently under testing for official release - 4.4.2024
-------------------------------------------------------

[](#currently-under-testing-for-official-release---442024)

[![example workflow](https://github.com/pivotalso/laravel-ab/actions/workflows/tests.yml/badge.svg)](https://github.com/pivotalso/laravel-ab/actions/workflows/tests.yml/badge.svg)

Laravel A/B by Pivotal is a package to help you create and manage A/B tests on your laravel blade templates. It also provides a way to generate and view reports locally or by integration into Pivotal AB services.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require pivotalso/pivotal-ab
```

Add the service provider in `config/app.php`:

```
    'providers' => ServiceProvider::defaultProviders()->merge([
        ...
        pivotalso\PivotalAb\PivotalAbServiceProvider::class,
    ]),
```

If you want to send your events to Pivotal AB, you must configure the library to listen for save events. Add the following to your `EventServiceProvider`:

```
  ....
  use pivotalso\PivotalAb\Events\Track;
  use pivotalso\PivotalAb\Listeners\TrackerLogger;

  class EventServiceProvider extends ServiceProvider {
       protected $listen = [
        ...,
        Track::class => [
            TrackerLogger::class,
        ],
    ];
```

as well as add `LARAVEL_AB_API_KEY` to your `.env` file You can get your api key from your project settings page on Pivotal AB.

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="ab-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="ab-config"

/// ab.php
return [
    'cache_key' => 'laravel_ab_user',
    'request_param'=> env('LARAVEL_AB_REQUEST_PARAM', 'abid'), /// listen for query string param to override instance id
    'allow_param'=> env('LARAVEL_AB_ALLOW_PARAM', false), /// allows for the use of request param
    'api_key' => env('LARAVEL_AB_API_KEY', ''), // the api key for pivotal intelligence
];
```

Documentation
-------------

[](#documentation)

You can find the documentation for this package at [https://docs.pivotal.so/docs/ab/laravel](https://docs.pivotal.so/ab)

Usage
-----

[](#usage)

Here is an example use case of a nested A/B test tracking signup and free trial goals

` welcome.blade.php`

```

        My Website

        @ab('hero-text')
        @condtion('my website')
            My Website
        @condition('welcome user')
            Welcome, {{ $user->name }}
                  @ab('free offer for new users')
                    @condtion('free trial')
                        Start your free trial
                    @condition('get started')
                        Get Started
                    @track('free trial')
        @track('sign up')

track('go-to-ab');
       if ($option === 'variant') {
           return view('variant-welcome');
        }
       return view('welcome');
    }
```

You can either track goals in views or within your application logic. ` register.blade.php`

```

        My Website

        .... body
        @goal('sign up')

has('free_trial')) {
            PivotalAb::goal('free trial');
        }
    }

```

Reporting
---------

[](#reporting)

You can view reports locally by running the following command

```
php artisan ab:report
```

a sample output would be

```
{
    "hero-text": [
        {
            "condition": "my website",
            "hits": 6,
            "goals": 3,
            "conversion": 50
        },
        {
            "condition": "welcome user",
            "hits": 12,
            "goals": 3,
            "conversion": 25
        }
    ]
}
```

You can also see report on your browser if you specify a reporting url, username, and password

```
LARAVEL_AB_REPORT_URL='/hidden/ab/reports'
LARAVEL_AB_REPORT_USERNAME='user123'
LARAVEL_AB_REPORT_PASSWORD='password123'

```

You can then visit `http://yourapp.com/hidden/ab/reports` to view your reports

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Rulian Estivalletti](https://github.com/82rules)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance65

Regular maintenance activity

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~16 days

Total

4

Last Release

724d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65c27a46e9e70beb8aaa7c6c8da6643d3fbc6a32deeb5ea1c9191e6f509a5af5?d=identicon)[wonderfulso](/maintainers/wonderfulso)

---

Top Contributors

[![82rules](https://avatars.githubusercontent.com/u/2653133?v=4)](https://github.com/82rules "82rules (65 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")

---

Tags

laravellaravel-ab

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pivotalso-pivotal-ab/health.svg)

```
[![Health](https://phpackages.com/badges/pivotalso-pivotal-ab/health.svg)](https://phpackages.com/packages/pivotalso-pivotal-ab)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.4k10.6M274](/packages/laravel-boost)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

17959.0k](/packages/lunarstorm-laravel-ddd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
