Question display randomization | XM Community
Solved

Question display randomization

  • 8 February 2024
  • 5 replies
  • 62 views

Userlevel 3
Badge +11

I added a block that only contains 1 question. I want this block/question to only appear 50% of the time. How do I go about this?

 

Typically I would go into block behavior and select question randomization, but where there is only 1 question in the block I am  at a loss as to how to go about it. I DO NOT want to add this to another block as I have my blocks on display logic based on embedded data and I want “all” (a random 50%) of my participants to see this, my participants only view blocks that are pertinent to them based off their embedded data values.

icon

Best answer by TomG 9 February 2024, 14:25

View original

5 replies

Userlevel 3
Badge +11

Hi @kgillis, If you prefer not to use JavaScript,  Add an embedded data element and name it something like "RandomNumber" - Use the following equation to generate a random number between 1 and 100: Copy code: Rand(1,100)

You can use JavaScript for this purpose. For example: 
java script code: Math.floor((Math.random() * 100) + 1);

After this, On the block containing your single question add Display Logic and set the condition to display the block when "RandomNumber" is less than or equal to 50.

This setup ensures that the block with the single question will only appear 50% of the time based on the random number generated for each participant.

Userlevel 3
Badge +11

@Umang Upadhyay I’ve never touched java script so I’m going to stay away from it for now. If I’m follow you correctly on setting the embedded data it should look like this?
 

Then for the question display logic set the condition to when the embedded value RandomNumber is equal or less than 50, is that correct? 

 

Userlevel 3
Badge +11

I can’t seem to edit my above comment - positing this here in hopes it can help somebody else out. After you’ve added the embedded field click “set a value now,” Insert Piped Text, Random Number, I set my min to 1 and my max to 2. 

I then went into the display logic for that question and set it to display if RandomNumber = 1

I took this several times in a row and each time I was assigned a 1 and therefor saw the question. I am going to go back in and change it from 1-2 to 1-50 and then if the value is equal to or less than 25 I’ll have it displayed. I’m not so sure there’s a “good way” to get a true 50% display.

Userlevel 7
Badge +27

@kgillis - Instead of using a random number, use a survey flow randomizer with evenly present.

Randomizer 1 of 2 evenly present

    Set Embedded Data:

        show = 1

    Set Embedded Data:

       show = 0

Question Block (containing question with display logic based on ‘show’)

Userlevel 3
Badge +11

@TomG This is what I ended up doing and it’s working perfectly in testing! I removed the RandomNumber embedded data altogether. I did not add in show embedded data either. Since it’s the last question on my survey I set up a flow randomizer just as you had suggested (I was getting hung up as you have to select at least 1 element and I was only focusing on the block/single question here). I just added in end of survey as the 2nd option and then made it set to display 1 of the 2 elements (end of survey or block 2). Thank you for getting me pointed in the right direction here, it’s working just as I hoped it would.

 

Leave a Reply