Full-stack
Full-stack A/B campaigns allow using Personizely's JS API to run custom changes right within your code.
Configuration
Editing each variation opens up a view where you can enable or disable features and define parameter values that will later be used on the frontend.
Usage
To run the full-stack campaign in your code, Personizely exposes the following functions.
ply.runCampaign(id)
This method runs a campaign and returns the campaign variation instance if not on control, and null if the user falls into the control group (make sure the campaign you are running is of a full-stack type)
id - the campaign ID (you can find it in the address bar when editing the campaign)
variation.getFeature(key)
Returns the feature instance within the variation.
key - the feature key as specified when creating it
feature.isEnabled()
Returns true or false depending on whether the feature is enabled for the current variation.
feature.getParameter(key)
Returns the value of the parameter of the feature within the current variation.
key - the key of the parameter as specified when defining the variation
Example
const variation = ply.runCampaign(1); // 1 is the campaign id
if (variation) {
const cartFeature = variation.getFeature('cart'); // is the feature id/key
if (cartFeature.isEnabled()) {
const message = cartFeature.getParameterValue('message'); // message is the feature parameter
this.notification.querySelector('.cart-notification__heading').childNodes[1].textContent = message;
}
}