Conditionally Piping Embedded Text Based on Survey Answers? | XM Community
Skip to main content

Hi!
I am currently creating a survey, and at the end of one of the blocks, I would like to have specific embedded data that I created be piped into the last question's text based on the previous answers within that block.
The previous questions ask participants how important a criteria is to them(multiple choice) where each criteria is the only text in separate questions and participants select the level of importance for that criteria. At the end I want to have a final question that says "You selected X, Y, and Z as being important criteria. If these criteria were met, would you be satisfied? yes or no". In this case, the "X, Y and Z" would be the question texts for questions that participants selected as being important.

What I have tried so far is to create embedded text with each of the criteria listed separately, but I do not know how to add the condition where if a respondent selects "important" for the answer to question 1, the embedded text for that question is piped into the final question.
Would anyone be able to help me solve this?
Apologies if my issue is not clear.

Create three embedded variables, lets call them Imp1, Imp2 and Imp3. In your final question, pipe the values into the question text. So it will be something like, You selected {e://field/Imp1} {e://field/Imp2} {e://field/Imp3}.... Now you need to fill up the values of Imp1, Imp2 and Imp3, with X,Y and Z, in case they are selected as important. There are two ways to go about this:
The first is to use JS. Assuming a multiple choice, single answer question, it would be something like this:
Qualtrics.SurveyEngine.addOnPageSubmit(function () {
    var sel_text = this.questionContainer.querySelector(".q-checked").nextElementSibling.innerText;
    if (sel_text.includes("important")) {
        Qualtrics.SurveyEngine.setEmbeddedData("Imp1", "X");
    }
});
Repeat it with the required changes for each question.

Alternatively, you could avoid JS and use branching. Move the final question to another block. Then after the block where you ask them for their preference. Make branches, one each for X, Y and Z. Trigger them only if important is selected. Within these branches, update the values of Imp1, Imp2 and Imp3 to X, Y and Z respectively.


Create embedded variables and use branching method using different conditions and then add pipein text in question text.


Leave a Reply