rcalmeida/ab
Composer 安装命令:
composer require --dev rcalmeida/ab
包简介
A server-side A/B testing tool for Laravel 5.
关键字:
README 文档
README
A server-side A/B testing tool for Laravel, a great free alternative for services such as optimizely. Use A/B testing to figure out which content works, and which doesn't.
This tool allows you to experiment with different variations of your website and tracks what the difference in engagement or reached goals is between them. Whenever you ask the A/B testing class for the current experiment, it will select the next experiment that has the least visits so that every experiment is tested equally. When there is an active experiment going on, it will start tracking engagement (click a different link, or submitting a form) and check if certain defined goals are reached. These goals are generally urls or routes, but can also be triggered manually.
Installation
Install using composer:
composer require rcalmeida/ab
Add the service provider in app/config/app.php:
'RCAlmeida\AB\TesterServiceProvider',
Register the AB alias:
'AB' => 'RCAlmeida\AB\Facades\AB',
Configuration
Publish the included configuration file:
php artisan config:publish rcalmeida/ab
Next, edit the config/ab.php file. The following configuration options are available:
Database Connection
This is your Laravel database connection that is used to store the A/B testing data. This is handy when you want to store the A/B testing data in a different database. When empty, it will use your default database connection.
'connection' => 'mysql',
Experiments
These are your A/B experiments. These are unique identifiers that you can use in your code or views to decide which version you should be showing.
'experiments' => [
'big-logo',
'small-buttons',
'short-form'
],
Goals
Without goals, each experiment will track the number of visitors that saw the experiment and detect engagement. Additionally, you can define certain goals that you want to reach with your experiments. If, your main goal is for your visitors to buy your product or contact you for more information, and you have specific routes set up for both of these pages, your goals could look like this:
'goals' => [
'pricing/order',
'contact'
]
Your goals can be relative urls, named routes or can be triggered manually.
Preparing the A/B test database
Once you have selected your database connection, use the included install command to prepare the required tables:
php artisan ab:install
The database structure is small and lightweight, so it will not impact your application.
Usage
After you have defined your experiments and goals, you can start designing your A/B tests. All your visitors will be given the next experiment that has the least visits. You can request the current experiment identifier with the AB::experiment() method. For example, if you have defined the following experiments ['a', 'b', 'c'], your view could look like this:
@if (AB::experiment('a'))
<div class="logo-big"></div>
@elseif (AB::experiment('b'))
<h1>Brand name</h1>
@elseif (AB::experiment('c'))
<div class="logo-greyscale"></div>
@else
// Original or default value
// This maybe appears when experiment has inactive
@endif
Once the visitor is assigned to an experiment, his next clicks are automatically tracked to see if he is engaging with your website or completing certain goals. These goals are relative urls or named routes, and will be marked as completed when a visitor visits that url during an experiment.
NOTE: Visitors are only tracked if you are conducting an experiment. Only when you ask the current AB::experiment(), it will assign an experiment to that user using the current Laravel session.
Adding new experiments
If you want to add new experiments, it may be best to clear the existing A/B testing data with this command:
php artisan ab:flush
If you don't flush your existing experimental data, all new visitors will see the new experiment first until it catches up with the pageviews of the old experiments.
Reports
A/B testing reports are available through an artisan command:
php artisan ab:report
This will generate a simple output containing the results for each experiment and their goals.
+------------+----------+----------------+---------------+---------------+---------------+
| Experiment | Visitors | Engagement | Buy | Contact | Pricing |
+------------+----------+----------------+---------------+---------------+---------------+
| a | 173,074 | 6.0 % (10,363) | 1.3 % (2,249) | 4.8 % (8,307) | 5.3 % (9,172) |
| b | 173,073 | 5.1 % (8,826) | 1.1 % (1,903) | 3.5 % (6,057) | 3.9 % (6,749) |
| c | 173,073 | 5.0 % (8,653) | 1.0 % (1,730) | 1.3 % (5,538) | 3.2 % (5,538) |
+------------+----------+----------------+---------------+---------------+---------------+
You can also export these reports to .csv format using this command:
php artisan ab:export /path/to/file.csv
If you run that command without a filepath, it will write it to the console.
Advanced
AB::pageview()
Used to manually trigger an pageview.
AB::interact()
Used to manually trigger an interaction which results in engagement.
AB::complete($goal)
Used to manually trigger goals. Useful when you want to track goals that are not linked to urls or routes.
AB::getExperiments()
Get the list of experiments.
AB::getGoals()
Get the list of goals.
AB::hasExperiments()
Return true if has more than 1 experiment into table "experiments".
AB::currentExperiment()
Return the name of the current session experiment.
Advanced
Edited and Fixed by Raphael Almeida
rcalmeida/ab 适用场景与选型建议
rcalmeida/ab 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.51k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「optimizely」 「laravel」 「split」 「AB」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rcalmeida/ab 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rcalmeida/ab 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rcalmeida/ab 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Optimizely PHP SDK for Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts
Optimizely SDK for Full Stack PHP projects.
Testing Suite For Lumen like Laravel does.
An Optimizely app for Strata
A server-side A/B/n testing tool
A/B testing tool for Laravel apps
统计信息
- 总下载量: 11.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-28