These docs are for v1.0. Click to read the latest docs for v2.0.

Getting Started

Taplytics decisions is an API to quickly use Taplytics features and functionality at edge.

Initialization

API client can be initialized as following.

$client = new TaplyticsLib\TaplyticsClient();

Class Reference

APIController

Get singleton instance

The singleton instance of the APIController class can be accessed from the API Client.

$client = $client->getClient();

createGetVariables

All variables and their values for the given user

function createGetVariables(
        $token,
        $userId,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
bodyOptionalAll relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$body = new Body();

$result = $client->createGetVariables($token, $userId, $body);

createGetVariationForExperiment

For a given experiment, determine whether or not a user is in the experiment, and in which variation

function createGetVariationForExperiment(
        $token,
        $userId,
        $experimentName,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
experimentNameRequiredName of an Experiment
bodyOptionalAll relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$experimentName = 'experimentName';
$body = new Body();

$result = $client->createGetVariationForExperiment($token, $userId, $experimentName, $body);

createGetVariableValue

Value for given Taplytics Dynamic Variable. If a user is not in an experiment containing the variable, the response be the provided default value in the query params.

function createGetVariableValue(
        $token,
        $userId,
        $varName,
        $defaultValue,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
varNameRequiredname of variable
defaultValueRequireddefault value to be used if user does not have variable available.
bodyOptionalAll relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$varName = 'varName';
$defaultValue = 'defaultValue';
$body = new Body();

$result = $client->createGetVariableValue($token, $userId, $varName, $defaultValue, $body);

createGetBucketing

Returns a key/value pairing of all experiments that the user has been segmented into, as well as the variation the users are assigned.

function createGetBucketing(
        $token,
        $userId,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for current user
bodyOptionalProvide all relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$body = new Body();

$result = $client->createGetBucketing($token, $userId, $body);

postEvent

Send an event to Taplytics. These events are then used to compare against an experiment's goals to determine the success of an A/B test.

function postEvent(
        $token,
        $userId,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
bodyOptionalProvide an array of events, as well as all additional relevant user attributes.

Example Usage

$token = 'token';
$userId = 'user_id';
$body = array(
	'events' => array(
	        		array('eventName' => 'event name!', 'eventValue' => 5)
				)
);

$result = $client->postEvent($token, $userId, $body);

The format for passing in events is as follows:

{
	attributes: {
		name: '',
		...
	},
	events: [
		{eventName: '', eventValue},
		...
	]
}

createGetConfig

Returns the entire configuration for the project. This is the document that informs the experiment information such as segmentation. Extremely verbose and should be used for debugging.

function createGetConfig(
        $token,
        $userId,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
bodyOptionalAll relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$body = new Body();

$result = $client->createGetConfig($token, $userId, $body);

createGetFeatureFlags

Returns the list of feature flags with names and key names.

function createGetFeatureFlags(
        $token,
        $userId,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
bodyOptionalAll relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$body = new Body();

$result = $client->createGetFeatureFlags($token, $userId, $body);
foreach($result as $flagObj) {
        // $flagObj->name to get the name of the feature flag
        // $flagObj->keyName to get the key of the feature flag
}

isFeatureFlagEnabled

Returns true or false based on if the keyName passed in is an enabled feature flag.

function isFeatureFlagEnabled(
        $token,
        $userId,
        $keyName,
        $body = null)

Parameters

ParameterTagsDescription
tokenRequiredSDK token for the project
userIdRequiredID for given user
keyNameRequiredkey name for the feature flag
bodyOptionalAll relevant attributes associated with the user

Example Usage

$token = 'token';
$userId = 'user_id';
$keyName = 'featureFlagKey';
$body = new Body();

$result = $client->isFeatureFlagEnabled($token, $userId, $keyName, $body);
if ($result) {
        showFeature();
}