Skip to content

Instantly share code, notes, and snippets.

@yatsenkolesh
Last active June 24, 2022 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yatsenkolesh/0124c56d22255496912661a3ed0824ab to your computer and use it in GitHub Desktop.
Save yatsenkolesh/0124c56d22255496912661a3ed0824ab to your computer and use it in GitHub Desktop.
<?php
use Abrouter\Client\Config\Config;
use DI\ContainerBuilder;
use Abrouter\Client\Client;
require '/app/vendor/autoload.php';
$containerBuilder = new ContainerBuilder();
$di = $containerBuilder->build();
$token = '04890788ba2c89c4ff21668c60838a00a87b1cf42c9c6b45d6aa8e11174f0d5762b16b6c09b6b822'; //you can find your token in ABRouter dashboard
$di->set(Config::class, new Config($token, 'https://abrouter.com'));
/**
* @var Client $client
*/
$client = $di->make(Abrouter\Client\Client::class);
$userSignature = $_SESSION['user_id'] ?? uniqid();
$experimentId = 'button_color_test';//experiment id is also there
$runExperimentResult = $client->experiments()->run($userSignature, $experimentId);
$experimentId = $runExperimentResult->getExperimentId(); //form-color
$branchId = $runExperimentResult->getBranchId(); //red
echo '<button style="color: '. $branchId .'">Hello</button>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment