goto
routes respondents to a question, labeled group, or page based on a condition being "true." After routing, the survey continues from that point and follows any page or group conditions thereafter.
5. Which of the following have you eaten in the past three months?
type: checkbox
instructions: Select all that apply.
randomize: y
1. Strawberry
2. Banana
3. Apple
4. Pear
5. Sweet potato
6. Carrot
7. Avocado
100. Notrealfood {goto: bad}
99. None of these {exclusive: y} {term: y}
Details
-
goto
can be used as a tag, element decorator, or standalone widget:-
Widget –
goto
is independent of other questions/variables and requires a question ID, page label, or group label as input. Use acondition
tag to define the trigger. For complex logic (e.g., Perl statements), use the widget. -
Tag –
goto
is attached to the question/variable the condition is based on and requires a target label or question ID as input. Use acondition
decorator to define the trigger, (e.g.,goto: bad {if anyChecked($Q5,100)}
). Multiplegoto
tags can be applied to the same question. -
Element Decorator –
goto
is attached to an option and is triggered when the option is selected. No condition is necessary. Multiplegoto
decorators can be used per question, one per answer option.
-
Widget –
-
goto
is mainly used for routing to system groups like"term"
for deferred terminations or"bad"
for respondents that fail quality checks. - Use the
onload
tag to executegoto
on page load instead of page submission.
Caution! goto
overrides group conditions, allowing respondents to enter a group even if its condition is false. However, group conditions are re-evaluated after each page submission, and if not met, respondents are routed out immediately.
Additional examples
Overriding deferred terminations
A common use case for goto
is to override a deferred termination. A respondent can be terminated before they reach the deferred term point by including goto: term
as a tag or widget along with the appropriate condition.
For example, if a survey uses defer term
to terminate respondents at the 'deferred' page, but respondents under 18 should be terminated immediately at QAGE, add the goto: term
widget and apply the same condition as the term if
tag.
appconfig
singlepage: y
defer term: deferred
AGE. What is your age?
type: integer
range: 1-99
termif: $QAGE < 18 {text: AGE | Under 18} {id: AGE} {goto: term}
1. Have you participated in any research on this topic in the past year?
type: radio
1. Yes {term: y}
2. No
2. Do you have any pets in your household?
type: radio
1. Yes
2. No
new page: deferred
text: The rest of the survey continues here.
Using 'goto' as a standalone widget
If the goto
tag cannot be easily applied, such as when termination depends on multiple questions, it can be used as a standalone widget.
In this example, respondents who are under 25 and live in the Northeast will be sent to a later point in the survey labeled 'YNE'.
3. What is your age?
type: radio
1. Under 25
2. 25-44
3. 45 or older
4. In what region do you live?
type: radio
1. Northeast
2. South
3. Midwest
4. West
goto: YNE
condition: anyChecked($Q3,1) and anyChecked($Q4,1)
Creating confirmation loops with the 'goto' decorator
Confirmation loops can be created with goto
to verify answers for previous questions and redirect the respondent to a previous question to edit their prior response(s).
In this example, respondents who claim to have 20 or more cats and dogs will be shown Q3. If they verify that they did answer the previous questions correctly, they can continue. If 'No' is selected at Q3, the goto
decorator routes the respondent back to Q1 so they can alter their responses for Q1 and/or Q2.
1. How many cats do you live with?
type: number
datatype: whole
size: 3
2. How many dogs do you live with?
type: number
datatype: whole
size: 3
3. You indicated you have 20 or more pets living with you. Is that correct?
showif: $Q1 + $Q2 >=20
type: radio
1. Yes
2. No {goto: Q1}
Comments
0 comments
Please sign in to leave a comment.