Currently Dual Kind only provides a script to be called form the web. The API endpoints can be used to track from any platform but there is no official support yet.

Installing on the web

To install for experiments you just need to include the script and initialize it with setup and your key.

<script src=""></script>

Activating the experiment

To activate the experiment call the activate function with the experiment key and a callback function which will receive the selected variation.

dualkind.activate("your-experiment", function(variation) {
    // Construct your UI from returned variation.

Parameter variation from the callback function can also be null if there is any error activating the experiment.

The activate function also accepts a variation name as a second parameter instead of a callback function. This allows to specify the variation that was activated in case you use Dual Kind just for storing the events and do the statistical analysis.

dualkind.activate("your-experiment", "control");

Additionally you can pass an unique identifier to identify the user if you don't want the API to generate one based on the request information.

dualkind.activate("your-experiment", "control", {"uniqueId": 2147483647});

The uniqueId value needs to be a value between -2147483648 and 2147483647 (4 byte, signed integer).

Tracking events

Tracking is done through the track function. If there is only one event to track (ie. using the activation to count how many people see the experiment and using a single convert event) you can call the function as follows:


Additionally you can pass the event to be tracked as a second parameter.

dualkind.track("your-experiment", "convert");

As with the activate function, it is also possible to pass a variation and uniqueId values.

dualkind.track("your-experiment", "convert", "control", {"uniqueId": 2147483647});

Helper methods

The Dual Kind JavaScript file also provides two additional helper methods to get started with showing experiments.

The replace function will replace the script tag it is executing in with the node based on the returned variation.

    function trackedLink(text, location, experiment) {
        var link = document.createElement('a')
        link.innerText = text;
        link.href = location;
        link.addEventListener('click', function () {
        return link;
    dualkind.activate('experiment', dualkind.replace({
        'control': trackedLink('Buy now', '#', 'experiment'),
        'other': trackedLink('Buy now $', '#', 'experiment'),

If the activate were to select the control variation it the whole script tag would be replaced by a link with text "Buy now" that would track every press.

Additionally you can use activateBalanced which will activate with one of the provided variations, in a random way, storing the selected variation in a cookie.

    var variation = dualkind.activateBalanced('experiment', ['control', 'other']);
    // Use your variation