Executing Code after an variation has been decided, experiment executed, or goal triggered

Issue

There are times we may need to execute code after an experiment variation has been decided, an experiment executed or a goal triggered. Executing code after these events occur is helpful to be able to send experiment data to third party analytics platforms and other situations.

Solution

We have launched javascript events to address these situations. Here you can have how they can be triggered:

  • experience.variation_decided - gets called each time a variation is being returned in order to be executed
  • experience.activated - run each time an experience is activated, after the experience changes have been triggered (aka code ran)
  • goal.triggered - executed each time a goal is fired ( a goal is fired only if it needs to be marked as triggered for a running experience)

To attach a listener, function to an event, the following is the structure:

_conv_q = window._conv_q || [];
_conv_q.push({
what: 'addListener',
params: {
event: 'experience.variation_decided',
handler: (event) => console.log(JSON.stringify(event))
}
})
  • The params.event needs to be one of experience.variation_decided, experience.activated and goal.triggered
  • The params.handler needs to be a function that receives as a parameter the event when it's called.

The parameter received by the handler has the following structure, for each of the three possible events:

  1. experience.variation_decided

    {
    "data":{
    "experience_id":"111111",
    "variation_id":"22222",
    "experience_name":"name here",
    "variation_name":"name here"
    },
    "event":"experience.variation_decided"
    }
  2. experience.activated

    {
    "data":{
    "experience_id":"111111",
    "variation_id":"22222",
    "activated_first_time":false,
    "experience_name":"name here",
    "variation_name":"name here"
    },
    "event":"experience.activated"
    }

    activated_first_time - is a boolean which is true if that experiment was now activated for the first time for that visitor.

  3. goal.triggered

    {
    "data":{
    "experience_id":"11111",
    "variation_id":"222222",
    "goal_id":"33333",
    "experience_name":"name",
    "variation_name":"name"
    },
    "event":"goal.triggered"
    }

     

Important
Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments