randomly present image (randomisation with JS) | XM Community
Question

randomly present image (randomisation with JS)

  • 26 September 2019
  • 3 replies
  • 20 views

Hello - I am trying to randomly show a picture in a question. The idea is that the respondents will have to answer questions on the specific image they see.

All the other information are randomised externally to Qualtrics and included in the platform using a JS code. I am wondering if there is the possibility of randomising also the picture name, and simply include the path to the picture as a variable (img src). The issue I encounter with that is that it looks like Qualtrics images' path cannot be constructed from the images' names. Example:

If image2 was randomly selected to be included, I would like to have something like:

src="https://uozdoe.qualtrics.com/CP/Graphic.php?IM=image2"

Instead, it looks like:

src="https://uozdoe.qualtrics.com/CP/Graphic.php?IM=IM_aeKrnXPrpG3WLkN"

Is there any way to change the paths?

Thanks for any help.

3 replies

Userlevel 7
Badge +6
You can use pipe text to append the URL string like you have above. I'd recommend also setting and embedded data value so that you easily know which image they had seen.
I understand, thank you for your answer. But how to get the correct image path?
My images are called "image_2", but they turn out to be" IM_aeKrnXPrpG3WLkN". Can I change back to image_2?
Userlevel 7
Badge +6
The image nickname is "image_2" but your file ID is IM_aeKrnXPrpG3WLkN. Your file ID is needed to pull the specific image. That is why I recommended using embedded data to set a value to tell you which image is displayed.

This can be done several different ways and the best way depends on how you programmed your survey. If Randomization and branching logic is used to select which image is scene, simply add the embedded data at the same time as the image is selected.

But essentially you can't tweak your URL to say "image_2" because your nickname of "image_2" doesn't mean anything.

Leave a Reply