Randomized trials with specific conditions | XM Community
Skip to main content

Hi All,
I'm very new to Qualtrics but have been reading their support pages for question and block randomization but haven't found a great solution for what I'm hoping to do.
I'm trying to have an image displayed for each trial. I'm going to have a total of 12 unique images, but I'm going to display them in 4 sequences of 3 images. For example sequence A could have image2, image3, and image10, sequence B could have image1, image4, and image9 etc. for sequenceC and sequence D (and four sequences total). I need each sequence repeated about 40 times each and I need the order from one sequence to the next to be random with no immediate repeat. So order of sequence A, B, A, C, D, etc. would be fine but A, B, B, A, C, D would not be fine because B repeats itself immediately. Additionally within each sequence the order of the images needs to be fixed for each time the sequence is displayed and finally, I need these sequences to be randomized for each subject (such that each subject doesn't have the same order within each sequence they're learning but within their own trials they have ordered sequences replayed for them).
I know this seems complicated, so I would greatly appreciate any help!

You should set embedded variables for the images in each sequence and the order of sequences. You'll need to use JavaScript or a webservice to set the values of the embedded variables based on your rules.


Hi TomG,
Thank you for your answer! As a follow-up question, would the JavaScript be for a "question" and then it set the value for the image to display? Before I go too far down a JavaScript hole is it possible to know what variable (image) was displayed in the last trial (or question) if I'm trying to loop through the same question?


Thank you for your answer! As a follow-up question, would the JavaScript be for a "question" and then it set the value for the image to display? Before I go too far down a JavaScript hole is it possible to know what variable (image) was displayed in the last trial (or question) if I'm trying to loop through the same question?

JavaScript is always attached to a question unless it is placed it the header/footer to execute on every page. In your case, to use JavaScript I think you want to:
  1. Define all your embedded variables at the beginning of the survey flow

  2. Attach the JavaScript to a question prior to presentation of your images and have it determine and set the values of all the embedded variables (the images in each sequence and the order of the sequences).

  3. Use the embedded variables to pipe or control flow as needed. I think you probably want to pipe the embedded variables into a loop & merge setup.


Leave a Reply