Activation API events

In addition to the usual methods and data structures provided by FigPii's Activation API — read more here — some custom window events are also fired by our JavaScript engine. They make excellent entry points to customize FigPii's behavior and extend our platform. For instance, you can listen to the FigPii::experiment.variation.loaded event to be notified in your own JavaScript code whenever a new experiment is loaded.

A full list of currently implemented events is provided below. If you think a useful event is absent from our current Activation API, do not hesitate to contact our team to ask for an improvement. It's easy for our developers to add new events which can suit your needs.

List of events

figpii::experiment.variation.decided

window.addEventListener('figpii::experiment.variation.decided', function(event) {
    const toolId = event.detail.toolId;
    const variationId = event.detail.variationId;

    const experimentName = FIGPII.settings.experiments[toolId].name;
    let variationName;
    if (variationId !== '-1') {
        variationName = FIGPII.settings.experiments[toolId].variations[variationId].name;
    } else {
        variationName = 'Disabled';
    }
});

This event is fired whenever a new variation is decided (ie, when the visitor matches the targeting of the experiment for the first time). As an experiment can be associated with extra options (such as the exclusion of a percentage of traffic or capping), it's possible for variation id to be -1, meaning the user was not included in the experiment.

figpii::experiment.variation.loaded

window.addEventListener('figpii::experiment.variation.loaded', function(event) {
    const toolId = event.detail.toolId;
    const variationId = event.detail.variationId;


    const experimentName = FIGPII.settings.experiments[toolId].name;
    let variationName;
    if (variationId !== '-1') {
        variationName = FIGPII.settings.experiments[toolId].variations[variationId].name;
    } else {
        variationName = 'Disabled';
    }
});

This event is fired whenever a variation is loaded — this can either be the first time this variation has loaded or the variation has loaded for a returning visitor.

For unique variation loads, i.e., the first time a variation loaded, refer to figpii::experiment.variation.decided.

As an experiment can be associated with extra options (such as the exclusion of a percentage of traffic or capping), it's possible for variation id to be -1, meaning the user was not included in the experiment.

Still need help? Contact Us Contact Us