Setting up display logic for survey questions
You can add display logic to your survey questions so that they are only shown to respondents if certain conditions are met.
To do this, click on the
.You can then add conditions based on:
- How respondents answered any additional questions.
- Respondent information that is recorded by Conjointly, including participant source.
- Any GET variables passed to the survey.
- JavaScript function (for advanced users).
- A group of conditions.
Displaying questions based on answers to previous questions
To display a question based on responses to previous question, follow these steps:
- Add a new condition using Condition based on answers to previous questions.
- From the Question dropdown, select the reference question.
- Select the desired Operator and Values (if applicable).

Displaying questions based on participant sources
If your experiment includes multiple sources of participants, you can display questions based on one or more participant sources using the following steps:
- Add a new condition using Respondent information.
- From the Variable dropdown, select Participant source.
- For Operator, select Any of these values or None of these values.
- Select the desired participant sources from Values.

Using JavaScript to set up display logic
In some instances, question display logic may be more complex than the basic logic builder can handle. For example:
- Computation on previous answers (such as computing BMI from height and weight).
- Display probabilities (e.g. 30% of respondents should see the question).
- Time spent in the survey so far.
It is possible to achieve that using JavaScript:

The basic format of this function is:
function test() {
return [CONDITION TO BE TESTED];
}
The test()
function should contain all the calculations and return a boolean value, which will determine whether the question is shown (if true
is returned, the question is displayed). Please note that the function may be executed multiple times (for example, early in the survey, when the survey script tries to pre-check if a question is likely to be displayed), so it should be designed not to affect variables outside the function itself.

Example 1: Show the question to approximately half of respondents
function test() {
return Math.random() < 0.5;
}
Example 2: Show on mobile only
function test() {
return ($(window).width() <= 480);
}
Example 3: Show on desktop only
function test() {
return ($(window).width() > 480);
}
Example 4: Show only if the sum of all values in the slider question Q6 is lower than 25
function test() {
return ($("#additionalQuestions6-frame").find(
'[name^="additionalQuestions"][name*="[slider][items]"][type="number"]'
).toArray().map(x => Number($(x).val())).reduce((a,
b) => a + b, 0) < 25)
}
Example 5: Show only to every first out of every three respondents
function test() {
var everyNth = 1; // You can modify this to change the position (say, not every first, but every second, third, etc.)
var among = 3; // You can modify this to change the denominator (say, among every three, four, five respondents)
var blockValue = parseInt($('input[name="block"]').val());
var residual = ((blockValue % among) + among) % among + 1;
return (residual == everyNth);
}
Using answers to other questions
To refer to previous answers in the survey, you must first identify the question field id via your browser’s developer tools, these might be something like id='additionalQuestions1-short-answer'
, in which case you could access the value with: $("#additionalQuestions1-short-answer").val()
. This value could then be processed with JavaScript and JQuery functions.
Applying conditional display logic in a conjoint study
In conjoint experiments, additional questions can be displayed based on the above configuration options and the use of conjoint levels.
Applying conditional display logic to blocks
Display logic can be applied to a simple, random, or monadic block, with the same configuration options available as for standard survey questions. Similarly, you can also present stimuli conditionally in monadic blocks.