Update Cookie with "Split Segmentation" Extension

davidmolina
Visitor
davidmolina

Hello,

I am using the Split Segmentation Extension to target a certain % of visitors in order to show them a contextual content. It creates a cookie wave1 with value "true" of 5% and "false" of 95%. I then mapped the cookie value within the associated Tealium variable to different marketing tools. 

Now my concern : I would like to update cookies value to 10% and 90%, and so on until reaching "true" = 100%.

How do I do this knowing that apparently Tealium set the new value dispatch only for new users that don't already have the cookie set. I could create a cookie "wave2" or something like this. The problem is values are randomly dispatched among user, and if I override the the new cookie wave2 values to my marketing tools, knowing that if a visitor was "true" in wave1, I also would like him to have a "true"value in wave2. 

Is this possible with a JS extension ? 

Since I have to go til wave10 or something, I would really appreciate if I wouldn't have to write too much code, since I am a beginner in JS !

Thank you,
David

1 REPLY 1
Highlighted

Update Cookie with "Split Segmentation" Extension

UnknownJ
Occasional Contributor
UnknownJ Occasional Contributor

Hi @davidmolina,

I think there are two steps here:

  1. Adopt a design pattern that suits your rollout approach, and
  2. Migrate to that pattern

With that in mind, rather than using a boolean true or false against a single variable, I would instead partition my users with a (randomly assigned) number from 0-99 and use that to drop them into the appropriate treatment.

You can get a random number from 0-99 with the following JS expression:

Math.floor(100*Math.random())

So let's say you've got a variable test1, which takes value from 0 to 99 - to run a 5% sample, simply use a condition:

test1 < 5

Now all you need to do is migrate your existing customers bsased on their wave1 value. You could do that with the following logic:

if(wave1 === true){
  // wave1 is set and the customer is in the first 5% sample
  test1 = Math.floor(5*Math.random());
} else if(wave1 === false){
  // wave1 is set and the customer is in the 95% remainder
  test1 = 5 + Math.floor(95*Math.random());
} else {
  // wave1 isn't set and the customer should be placed at random
  test1 = Math.floor(100*Math.random());
}

This should then give all your existing wave1 members a number from 0-4, all the wave1 non-members a value from 5-99, and all new customers a value from 0-99, evenly distributed. Then you simply need to update your test condition to ensure that the right number of customers are included.

Give me a shout if any of that is unclear.

Cheers,
James