Client Side (JavaScript) API
PUSH Calls
customEvent
Trigger a custom goal event
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'custom',
eventName: 'user-did-something', //api name of the goal
eventValue: 0 //optional (int or float)
});
forceVariation
Force a user into a specific variation
Please note that the call must be fired before ABlyft starts
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'forceVariation',
experimentId: 12345678,
variationId: 98765432
});
activatePage
Activate a specific page for the user (triggers the targeting check)
//By pageId
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'activatePage',
pageId: 12345678
});
//Or by pageApiName
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'activatePage',
pageApiName: 'all-pages-with-api-trigger'
});
deactivatePage
Deactivate a specific page for the user
//By pageId
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'deactivatePage',
pageId: 12345678
});
//Or by pageApiName
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'deactivatePage',
pageApiName: 'all-pages-with-api-trigger'
});
enableTrackingConsent
Enable the tracking consent
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'enableTrackingConsent'
});
disableTrackingConsent
Disable the tracking consent
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'disableTrackingConsent'
});
Hooks / Listeners
lifecycleEnd
Allows you to fire a callback when ABlyft has finished running
function onLifecycleEnd(){
console.log('ABlyft lifecycle ended');
}
window['ablyft'] = window['ablyft'] || [];
window['ablyft'].push({
eventType: 'addListener',
listener: {
type: 'lifecycleEnd',
handler: onLifecycleEnd
}
});