The custom scripting is used to change the flow of surveys or take actions based on customized, user-defined triggers. These triggers are based on the responses to the questions.
QuestionPro offers a custom logic engine to apply code scripts in the Apache Velocity language on branching and looping. Velocity is a Java-based template engine that provides a template language to reference Java objects. You can configure this question to apply code scripts on branching and debugging with the below settings.
Logic includes branching: If you want to jump to a question based on specific conditions, enable this option. The survey will skip rest of the questions and jump to the destination as configured in the script code.
Logic includes looping:If you want the survey to loop through one or more questions, enable this option. It will display a set of questions repeatedly. The system saves multiple rows of data for each loop executed.
Debugging:This option is used for debugging the execution of the script code. You can check the output after each command is executed.
Auto-Submit:To auto-submit the page after script execution, enable this option. The survey will move to the next page without clicking on the 'Next' button.
For a custom logic engine question to function correctly, you need to add a page-break after the question.
Consider a sports equipment manufacturing company that wants to conduct a customer satisfaction survey. If the survey participants give a poor rating, they want to ask further questions asking reasons for their grade.
The survey makers can use the custom logic engine question and add the below script to branch the survey to the relevant question.
Let's say, Q2 is a matrix question. Then, you can reference sub-questions in a matrix as Q2_1 for the first question, Q2_2 for the second, and so on.
If the respondent has rated 1 or 2 in the first sub-question, then the survey jumps to Q3. Similarly, if the respondents have rated low in the second and third sub-questions of a matrix question type, the survey branches to Q4 and Q5, respectively.
Course evaluation survey: The survey creator can ask the same set of questions for different courses. For each course, the survey can loop through the questionnaire.
Restaurant evaluation survey: Restaurant chains often conduct an online survey to collect customer feedback. If they have visited multiple food joints, the study would ask questions that compare the performance of the various outlets. You can use the custom logic question to set the custom variable with the restaurant name or location and ask questions specific to it.
Apart from branching and looping, you can use custom scripts for the below:
Calculating the score of a matrix question
Branching open-ended questions
Shorter questionnaire: By looping through a common set of questions, survey makers don't need to add them again in the questionnaire. They can reuse the existing ones any number of times.
Custom survey path: While there are many ways to add logic and customize the flow of the surveys, the custom logic engine enables you to direct respondents to specific questions and pages based on their response. If your requirements cannot be met with the standard survey logic methods, you can use the custom logic engine to set conditions.
Learn how to set up and use this feature with the following help resources: