Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - Optimizely A/B Testing
OP Custom Tag - Optimizely A/B Testing
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 6 months ago

Overview

This custom tag captures Optimizely A/B testing rules.

Under Variable Summary in ObservePoint data, select the Optimizely Data account to see the relevant variables.

  • amount: Shows the number of Optimizely data points for each URL.

  • enabledRules.xx: Shows the Optimizely script that is set for each URL.

  • optimizelyObj: For each URL if the Optimizely object is not present, not found is shown.

  • page: Shows the URL page name for each URL.

To capture these details in an Audit or Journey, paste the snippet below into an Execute Action:

function opReqGetAsync(paramObject, acct, callback) {
var baseURL = "https://opreq.observepoint.com/?acct=" + acct;
var opReq = new XMLHttpRequest();
opReq.onreadystatechange = function() {
if (opReq.readyState == 4 && opReq.status == 200) {
callback(opReq.responseText);
}
}
opReq.open("POST", baseURL, true);
opReq.send(JSON.stringify(paramObject));
}
var optimizelyTesting = function() {
var object = {},
rules = {},
optimizelyObject = window['optimizely'];
object.page = location.href;
object.optimizelyObj = 'not found';
if (typeof optimizelyObject == 'object') {
object.optimizelyObj = 'found';
var experiments = window.optimizely.allExperiments,
variations = window.optimizely.data.variations,
keys = Object.keys(experiments);
for (var i = keys.length - 1; i >= 0; i--) {
var option = experiments[keys[i]].enabled_variation_ids;
for (var j = option.length - 1; j >= 0; j--) {
rules[option[j]] = variations[option[j]];
};
};
object.amount = Object.keys(rules).length;
object.enabledRules = rules;
}
opReqGetAsync(object, 'Optimizely Data');
};
optimizelyTesting();
Did this answer your question?