A/B test
A/B testing in Blings MP5 (variants via SDK + UTM for analytics)
This page explains a simple, reliable way to run an A/B (or A/B/C…) test in Blings MP5 by:
Picking a variant from URL if provided, otherwise select randomly
Passing it into the MP5 data fields (so Studio/Flow can react to it)
Persisting it into UTM parameters for analytics/BI.
Store it in localStorage so refresh will show the same version
Full demo code
Copy the code below to Blings Platform ⇒ Integration ⇒ "advanced" code
// Test #1 (you can add multiple)
runStickyABTest(params, {
testName: "abtest1", // <<=== Update with your variable name.
// Make sure to create the variable in the data-schema inside Blings Studio or Platform->settings page
variants: ["10off", "free-trial", "summer-promotion"], // <<=== Replace with the A/B options
utmSlot: "utm_source", // <<=== pick an available UTM slot, or leave it empty
});
// COPY ONCE
/**
===========================
Blings Sticky A/B Tests
===========================
* Runs one sticky A/B test.
* - If params.data[testName] already exists (and valid), it will be saved (stickied).
* - Else it will reuse localStorage if available.
* - Else it randomly picks one, saves it, and writes it into params.data[testName].
* - Always mirrors result into params.utmParams[utmSlot] for BI.
*/
function runStickyABTest(params, { testName, variants, utmSlot }) {
params = params || {};
params.data = params.data || {};
params.utmParams = params.utmParams || {};
const key = `blings_${testName}`;
const pick = () => variants[Math.floor(Math.random() * variants.length)];
const value =
(variants.includes(params.data[testName]) && params.data[testName]) ||
(variants.includes(localStorage.getItem(key)) && localStorage.getItem(key)) ||
pick();
params.data[testName] = value;
localStorage.setItem(key, value);
if (utmSlot) params.utmParams[utmSlot] = value;
return value;
}Where to use the variant inside Blings
Once params.data.abtest1 is set, you can use it in two common ways:
A) Scene selection (Flow Map)
Route users into different scenes/paths based on the variant (a / b / c).
B) Content selection (Studio)
Show different copy, visuals, or offers. E.g add "text connector" and set it's data replacment based on abtest1

Verification
Make sure to verify the A/B test works. Since it's "sticky" by default, meaning refresh will open the same test variant over and over, you can open a new "incognito" window every time, and see that the correct content is presented.
Another way will be to run the following command on the console: localStorage.clear()
Last updated
