Skip to content

Commit 45352b1

Browse files
Update moatOnDecision.js
1 parent 894b1af commit 45352b1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
//Fetch Optimizely State
22
var state = optimizely.get('state');
3-
//Get the current Decision String from the state
3+
//Use the getDecisionString API to get a string with relevant data from customer
44
var string = state.getDecisionString({"campaignId":campaignId,"shouldCleanString":true});
5-
//Check for a truthy value for the string indicating a visitor has been successfully bucketed
6-
if (string) {
7-
//create or update the window-level optimizelyMoat array with the Decision String if
5+
//Check for a truthy value for the string indicating a visitor has been successfully bucketed and is relevant for tracking
6+
if(string){
7+
//Split the generated string, replacing colons with '|' after the first to fit within Moat's slicer logic
8+
var array = string.split(':');
9+
var key = array[0];
10+
var value = array.slice(1).join('|');
11+
var pipe_string = key + ':' + value;
12+
//Push value new value to optimizelyMoat object
813
window.optimizelyMoat = window.optimizelyMoat || [];
9-
window.optimizelyMoat.push(string);
14+
window.optimizelyMoat.push(pipe_string);
1015
}

0 commit comments

Comments
 (0)