PHP code example of ringierimu / experiments

1. Go to this page and download the library: Download ringierimu/experiments library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ringierimu / experiments example snippets


composer 

php artisan experiments:install



return [
    'recommend' => [
        'control' => 'personalize',
        'test' => 'alice',
    ],
];

return [
    'recommend' => [],
]

 protected $middlewareGroups = [
        'web' => [
            Ringierimu\Experiments\Http\Middleware\SetExperiment::class

if (SdcExperiments::getOrStartExperiment('my-experiment') == 'test') {
    // the test experience
} else {
    // the control experience OR the experiment is not running
}

SdcExperiments::googleTagManagerSetTrackingVars();

[
    'tests' => [
        'ab_test' => [],
    ],
    'groups' => [
        'ab_test_nice_group_name' => [
            'id' => 'GOOGLE_OPTIMIZE_EXPERIMENT_ID',
            'variations' => [
                'ab_test',
            ],
        ],
    ],
]

[
    'tests' => [
        'ab_test' => [],
        'large_font' => [],
        'obnoxious_colours' => [],
    ],
    'groups' => [
        'ab_test_nice_group_name' => [
            'id' => 'GOOGLE_OPTIMIZE_EXPERIMENT_ID',
            'variations' => [
                'ab_test',
            ],
        ],
        'style_test' => [
            'id' => 'MULTIVARIANT_GOOGLE_OPTIMIZE_EXPERIMENT_ID',
            'variations' => [
                'large_font',
                'obnoxious_colours',
            ],
        ],
    ],
]