Evaluating branch logic in JS | XM Community
Solved

Evaluating branch logic in JS

  • 28 June 2021
  • 2 replies
  • 19 views

Hi,
As many others before us, we are struggling with inexact progress bars when there are a lot of optional blocks in a long survey, causing participants to drop out.
Is there a way to evaluate, in JS, if some particular branches in the survey flow will be taken or not (before they've been reached by the participant)? Ideally I don't want to hardcode the logic in the JS as this is error prone, but instead use the same logic as the existing survey flow.
Thanks in advance!

icon

Best answer by Yarin 30 June 2021, 19:04

View original

2 replies

Userlevel 3
Badge +8

You could use Embedded in your survey flow for each branch. Once set you can use subsequent branches and JS with the embedded data variables.

That doesn't sound like it will work since I need to know which blocks I will reach before Qualtrics has gotten there.
I ended up solving this by injecting generated Javascript (if ("${q://QID5/....}") { ... }) in the footer evaluating the survey flow of the survey at run-time. A bit cumbersome, but seems to work.

Leave a Reply