If you want your survey to make decisions based on a complex logic, you can enable this by using Custom Scripts. Simply put, Custom Scripts are short transcripts of code that'll run in the backend of the survey based on the input received from the user.
You can use custom scripts for two operations:
Custom Script for Conditions: Can be used to configure a logic based on which an action should happen.
Custom Script for Piping: Can be used to pipe a response and reuse it in the survey form.
Although Zoho Survey has built-in logic for enabling conditions, in certain scenarios, using built-in conditions would be time-consuming and repetitive. Under these circumstances, a single script of code can help your survey run the desired logic than multiple repetitive conditions.
Given below are the various scenarios where custom script for conditions can be implemented in Zoho Survey with their specific use cases:
Question Display Logic
Answer Display Logic
Page Skip Logic
Trigger Email
Survey End Page
Let's understand how Question display logic can be easily configured using custom script.
Imagine your organization wants to rollout an Insurance scheme to your employees based on the age categories mentioned below:
Scheme I: Age 25 - 40
Scheme II: Age 41 to 55
Scheme III: Age 56 to 70
Based on the DOB collected, the age of each individual should be calculated, and consequently, only a particular set of questions applicable to each age category should be shown to the attendee.
Since it is a complex piece of logic, a custom script should run to calculate the age of the respondent from the DOB he entered and then return a condition based on which the questionnaire suited to their age category can be shown.
Learn more about how to configure the steps for Question display logic using Custom Script in this page
----------------------------------------------------------------------------------------------------------------
Consider there's a question with multiple options that should be displayed based on a complex logic. In this case, the custom script can be used to enable the logic.
For instance, a health survey where options for a question should be shown based on the age of the responder. The only input the survey has here is the date of birth (DOB), from which the age of the responder should be calculated.
Here's how you can create a simple custom script and apply this logic:
Create the question and add all the options.
Click on the question and choose Answer Display Logic. Choose the condition based on which the choice should be shown or hidden, and select the applicable choices.
In the condition, choose based on Custom Script and add the codes to return True.
You can refer to the screenshots of the above example below to get an understanding.
The Page Skip logic is useful in scenarios where the survey is extensive and attendees need to answer only certain pages.
Consider a mattress company Sleep Well is organizing a volunteer call for testing the comfort of their latest mattress Lux Layers by selecting apt product testers through a market research survey.
Now they are creating a psychometric survey with a questionnaire of 10 questions, with a score assigned to each question. The average score of the total questionnaires should be taken, and if the respondent scores above 80%, they should be taken to a new page with a second set of questions collecting their contact details. If not, the participants should be directed to the Survey End page with a thank you message.
This logic can be configured using the Page Skip logic, wherein only the qualifying participants will be redirected to the Personal details page, and the disqualified applicants will be shown the Survey End page.
Another example would be a customer feedback survey for a product wherein there are five questions, each tied to a score. In the first page, a common questionnaire will be shown to assess the satisfaction level of the respondent. If the average score comes above 60%, it means the customer is satisfied. However, if the score is below 40% and you wish to delve deeper by directing to a second page with specific questions to understand the causes of dissatisfaction, it can be done via using the Page Skip logic.
Brew Bliss Co. is providing an opportunity for product testers by crowd-sourcing taste-testing for their newest craft coffee blend, Velvet Brew. They are selecting suitable testers through a market research survey to gather feedback on flavor profiles, aroma, and overall satisfaction.
Eligible applicants should be notified by an email invitation of their selection if they score an average above 70% in knowledge of various parameters used for coffee testing. However, an email shouldn't be sent for participants who score below 70%. So, a psychometric evaluation survey with a score assigned to each question can be created and shared via social media, and all the participants who pass the required score will receive the trigger email.
Your company is organizing a recruitment drive, starting with an entirely online phase. Applicants are required to take an online aptitude test featuring 30 questions, each worth 1 point, with a passing score of 16. The results should be displayed immediately after the test to the applicants, and this kind of scenario can be easily implemented by using a custom script in the survey end page.
You can enhance your survey's personalization using the piping feature. This allows you to tailor questions based on variables from earlier responses, making respondents feel more at ease when answering. For complex scenarios like piping the answer of an arithmetic operation, custom script can be used.
The custom script for piping can be used in the Survey End Page and Survey Disqualification page as follows:
Imagine you wish to integrate multiple conditions into a question.
For example, a survey is prepared, taking inputs like Name, Gender, and Marital status. Based on the inputs received for gender and marital status, the survey should address each respondent as Mr/ Mrs/ Miss in the subsequent questions.
If the respondent is an unmarried woman, then she should be addressed as Miss, while a married woman should be addressed as Mrs.
This logic cannot be configured using built-in conditions, but can be piped using a custom script.
For an online exam, the marks obtained need to be calculated and converted into grades. The grades are stored as a custom variable, then should be piped to a URL link in order to share them to another site where online certificates will be issued to the participants. This process can be implemented using a custom script that redirects users to the new page for certificate issuance.
Consider a customer feedback survey, wherein there's an option for a gift-card for your service if the customer started using your product before a certain date. You have provided a question asking ”When did you start using our service?”, and there's a follow up choice question asking "Do you want the gift card?".
Now imagine for the customers who are not eligible for the gift card that you need to build logic in the survey and show them a custom message like "Since you only started using our product [X] months ago, you are not eligible for the gift card."
This scenario can be implemented using a custom script that redirects users to the new page for certificate issuance.
Now imagine for the customers who are not eligible for the gift card that you need to build logic in the survey and redirect them using the Survey Disqualification page to another webpage. This scenario can be built using the custom script.
Now that we've covered the various use cases of Custom Script, let's see the programming languages you can implement to enable custom script in Zoho Survey.
JavaScript is a versatile and widely-used programming language that can be used for client-side scripting in web browsers. In Zoho Survey, you can use Java Script for conditions and piping in the following modules.
These are the various features where Javascript custom script can be used:
Question Display Logic (link to new doc)
Answer display logic
Page Skip Logic
Trigger Email
Survey End Page
Survey Disqualification page
Deluge is a scripting language used primarily within the Zoho ecosystem. It stands for Data Enriched Language for the Universal Grid Environment and is designed to help users automate tasks and customize applications in Zoho’s suite of products. Read more about Deluge
These are the various features where Deluge custom script can be used for conditions:
Trigger Emails
Survey End Page
These are the various features where Deluge custom script can be used for piping:
Survey End Page
Survey Disqualification page
Snippets are accessible to all Pro and Enterprise plan users.
The points given below are common for both JavaScript and Deluge:
If your survey is multilingual, you need to enter the specific language’s translation code to enable the condition or logic within the survey. For example, for the Tamil language, "ta" should be given.
If you have added conditions using the Date & Time question, then you have to use the same date format used in the previous question.
You can do sample tests while adding conditions to questions/pages.
To test, enter the code, then click Test with sample data. This will generate the sample data.
Click the Run button to view the sample result. You can add code and regenerate or modify the sample data as many times as you want to test.
To track the flow of the code, you can use the log feature provided in the insert variable box. You can view the log along with the result of the sample test.
Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.
If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.
You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.