With the predefined JavaScript Event Integrations it is possible that ABlyft triggers functions on your website or executes any JavaScript.
Unlike custom integrations, the code to execute is not hosted and executed at ABlyft, but triggers an event that you can listen to from your side.

Two hooks are available which can be used for this purpose:

  1. userBucketed:
    The event is fired when a user is assigned to a variant. This happens once.
  2. experimentViewed:
    The event is fired every time the experiment is running for the user (e.g. at every page request, if the targeting conditions are met).

How do you listen to the event?

//Bind Event for "userBucketed"
document.addEventListener('userBucketed', function(e){
    console.info("The Variation ID is: ", e.detail.variationId);
});

//Bind Event for "viewedExperiment"
document.addEventListener('viewedExperiment', function(e){
    console.info("The Variation ID is: ", e.detail.variationId);
});

What variables are available in it?

The values are available under the object "e.detail". See the example above.

  • projectId
  • projectName
  • experimentId
  • experimentName
  • variationId
  • variationName

Example

This on your side.... 

leads to...

Did this answer your question?