comocode/laravel-ab

Laravel 5 的 Blade 级 AB 测试

0.3.0 2016-07-18 21:33 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:21:21 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version Daily Downloads

laravel-ab

Laravel 的 A/B 测试套件,允许进行多个嵌套实验。

这将创建可追踪的实验,条件数量由您决定。并且将根据提供的关键词跟踪每个实验的转化率。

您可以有嵌套实验,其条件是常规的 VIEW 输出,这使得实验很容易添加/删除到您的项目中。

用法

使用 composer 或您喜欢的任何方式安装

composer install comocode/laravel-ab 

然后将服务提供者添加到 config/ 文件夹中的 app.php 中,如下所示

    ..Illuminate\Validation\ValidationServiceProvider::class,
    
    ..Illuminate\View\ViewServiceProvider::class,
    
    ComoCode\LaravelAb\LaravelAbServiceProvider::class

注册服务提供者后,您可以运行 php artisan 并查看以下输出

ab:migrate          migrates Laravel-Ab required tables

ab:rollback         removes Laravel-Ab tables

ab:report <experiment>  --list outputs statistics on your current experiments or the one specified in the command

您可以使用 ab:migrate 命令创建所需的表,并使用 ab:rollback 命令在需要查看实验结果时删除它们,使用导出命令查看统计信息

创建实验

有几个 PHP A/B 和其他 Laravel 包可用。

该项目专注于提供使用易于使用的 blade 接口测试多个实验,包括嵌套实验的能力。

  </div>
    @ab('My First Experiment') ///// the name of the experiment
    @condition('ConditionOne') /// one possible condition for the experiment
    <div class="uk-grid">
        <div class="uk-width-1-1 uk-text-center">
           @ab('My Nested Experiment') /// an experiment nested within the top experiment
                @condition('NestedConditionOne')
                    <h3>Some tag</h3>
                @condition('NestedConditionTwo') /// some values
                    <h3>Some other tag</h3>
                @condition('NestedConditionThree')
                    <h3>Another tag</h3>
            @track('NestedGoal') /// the goal to track this experiment to
        </div>
    </div>
    @condition('ConditionTwo')/// condition for top level test
        <h1> other stuff </h1>
    @track('TopLevelGoal') /// goal for top level test

要触发事件,只需执行以下操作

  @goal('NestedGoal')   

在目标页面或通过利用 app()->make('Ab')->goal('NestedGoal') 在您的应用程序执行中的任何地方。

加权条件

如果您希望将决策偏向特定条件,可以添加一个声明来控制分布。例如

 @ab('My Nested Experiment') /// an experiment nested within the top experiment
    @condition('NestedConditionOne [2]')
        <h3>Some tag</h3>
    @condition('NestedConditionTwo [1]') /// some values
        <h3>Some other tag</h3>
    @condition('NestedConditionThree [1]')
        <h3>Another tag</h3>
@track('NestedGoal') /// the goal to track this experiment to

将随机选择一个结果,但会根据权重总和(1 + 1 + 2 = 4)与特定权重 2/4、1/4、1/4 的比例计算结果的机会。

结果

一旦实验执行完成,它将记住提供给用户的选项,因此实验选择不会在重新访问项目时更改。

每个实例都会记录一个实验,目标会跟踪到实例,允许对每个条件的结果进行聚合。

贡献

请随时贡献,因为 A/B 测试是任何组织的重要部分。

待办事项

添加可排队的作业以在 cron 上发送报告,添加 HTML 图表