Sometimes experiments are not supposed to start automatically when the page is loading. Instead it might be better to activate it after a user does a specific interaction on the page. For example when he adds something to the shopping cart.
For this use case there is the experiment type "manual". You have two choices for triggering the experiment. You can either use a JavaScript command that can be attached to an element of the page. Or you build a JavaScript method and use for Targeting.
In addition you can use the standard targeting, but for manual experiments the targeting will only be evaluated in addition to the manual trigger.
To use the manual experiments go to the section "Settings" and choose "Manual" in the Type-Dropdown.
Activation by JavaScript Command
For triggering the experiment externally use:
window._bb.push(['activate experiment', experimentId, [stepIndex]])
_bb.push(['activate experiment', {{experimentId}}, {{stepIndex}}]);
experimentId is the ID of the experiment, which you want to activate.
stepIndex (optional) if the experiment has several steps, you can pass the index of the step
Custom JavaScript Targeting
As an alternative you can trigger the experiment by Javascript. In the section Targeting check the box "Use custom JavaScript targeting" and add your JavaScript.
Custom JavaScript can be used to extend the targeting capabilities by custom logic. The code must always return a value. The value will then be used to determine whether a user should fall into the targeting or not. A falsy value (e.g false or 0) will be treated as ‘No match’, whereas truthy values (e.g true or 1) are considered a 'Match’.
You can also return a promise, if you want to run asynchronous operations. The promise constructor is automatically polyfilled for browsers, that do not support it natively. Make sure to always resolve a promise with a truthy value. A rejected Promise or erroneous JavaScript is always considered a 'No match'.
Optional Custom Targeting
In addition to the two methods above the standard targeting can be used. It will be evaluated after the activation.
Check the box "Use custom targeting" in the section targeting.
Comments
0 comments
Please sign in to leave a comment.