Best practice for storing randomized JS data for complex Loop & Merge study (25 iterations)? | Experience Community
Skip to main content
Question

Best practice for storing randomized JS data for complex Loop & Merge study (25 iterations)?

  • January 13, 2026
  • 1 reply
  • 20 views

Forum|alt.badge.img

Hi everyone,

I am building a conjoint experiment involving 5 different product blocks. Each product block uses Loop & Merge to display 5 randomized scenarios to the participant (25 total decision scenarios per respondent).

The Setup:

I am using JavaScript to generate randomized attributes for each scenario (e.g., Price, Credit Balance, Payment Terms, Credit Limit). The randomization logic is complex (e.g., Credit Balance depends on the Credit Limit assigned earlier).

The Problem:

I initially tried calculating these values inside the loop and saving them using Qualtrics.SurveyEngine.setEmbeddedData. However, this caused data overwriting issues.

I then tried "Pre-Calculating" all 25 values at the start of the survey and saving them to distinct Embedded Data fields (e.g., shoe_price_1, shoe_price_2... bag_price_5).

Current Roadblocks:

  1. Reliability: setEmbeddedData seems to have "handshake" issues where the data isn't always committed to the server in time for the next block to display it (showing blank or "undefined" values).

  2. Setup Load: This requires manually initializing over 125 separate variables in the Survey Flow to ensure they are captured, which is error-prone and will honestly be super taxing.

My Proposed Solution (The "Shadow Storage" Method):

To bypass the Embedded Data sync issues, I am considering calculating all 25 scenarios in a single JavaScript block at the very beginning. I would then concatenate the entire dataset into a single string (e.g., Loop1_Data::Loop2_Data::...) and force-write it into a Hidden Text Entry Question using jQuery.

My Questions:

  1. Is writing to a hidden Text Entry question considered a more reliable method than setEmbeddedData for ensuring complex randomized data is captured in the final export?

  2. For the syntax, is jQuery("#QR~" + this.questionId).val(finalString) the standard way to target a question's input box from within its own JavaScript, or is there a safer API method? How exactly can I ensure the displayed value gets stored in the embedded data.

I want to ensure that my randomization data is 100% safe for analysis later. Thanks for any advice!

1 reply

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 16, 2026

I think the ideal way to handle it is with a web service that populates all embedded data fields. Then pipe those embedded data fields into your loop & merge fields (I’ve done it this way hundreds of times).

If you use JS to populate the embedded data fields, you first have to define them all in the survey flow (if you want them saved).  The only disadvantage to embedded data fields is defining them in the survey flow.  The advantage of embedded data fields is the naming would more straight forward. If I were using a question, I would used a form question and use Qualtrics JS API setChoiceValue()  to set the values.