How to save randomly generated JavaScript options? | XM Community
Skip to main content

How to save randomly generated JavaScript options?

  • February 18, 2023
  • 2 replies
  • 35 views

I have a survey question that generates a random string using JavaScript code, which updates an HTML element to display the string and allow responders to rate qualities of the string. I was wondering if there was an efficient way to somehow save the random string that gets generated so that it is displayed in the data report and I can see what string the responder was rating.

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • February 19, 2023

Define an embedded data field in the survey flow, then save the random string to the embedded data field in your JS.


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • February 19, 2023

https://community.qualtrics.com/XMcommunity/discussion/24045/how-to-save-randomly-generated-javascript-optionsAs for setting embedded data, you can use:
Qualtrics.SurveyEngine.setEmbeddedData( 'embeddedDataVariable', value );
Just make sure that that embedded data element exists in your survey flow before you set it.
Hope it helps!