Variables
Sometimes referring to an answer chosen earlier in the survey is not enough. You may want to cluster respondents by many conditions, based on the way they answered different questions, their known demographics etc. You can declare and alter variables throughout the survey and then adjust survey logic accordingly.
If your survey is a quiz, you can increase or decrease the running score for each respondent as they fail or succeed answering your questions. The value of your variable will be kept individual for each respondent and you can refer to it when you are ready to show the results or alter survey experience based on their achievements.
Please note: Instead of "QuizScore" you can use any alphanumeric variable name that suits your needs (A-Z, a-z, 0-9,_). Underscores are allowed.
- [QuizScore = 0] - Initializes variable "QuizScore" with the value 0.
- [QuizScore + 1] - Adds 1 to the value of variable "QuizScore"
- [QuizScore - 5] - Subtracts 5 from the value of variable "QuizScore"
Another example: you can create a variable "NPS" and assign respondents value "Promoter" or "Detractor" based on the answers they gave on your NPS (Net Promoter score) question. Later on you can append an extra modifier to the variable, if you find them to be an influencer on top of being a Promoter.
- [NPS = "Promoter"] - Initializes variable "NPS" with the text value "Promoter"
- [NPS + "and Influencer"] - Adds "Influencer" string to the "NPS" variable: resulting in "Promoter and Influencer"
As you can see from the examples above, variables can store text or numbers for further use in the logic.
To simplify things aytm Logic doesn't require you to declare variables so you can start using them where you want. The type of variable (text or numbers) is determined on initialization when you used it for the first time. By default each variable stores an empty value "". You can use the following characters in the name of the variable: A-Z, a-z, 0-9 and the underscore symbol "_". Variable names must always begin with a letter. String values of variables must be surrounded by quotes and may contain any character. Variable names cannot be identical to a few reserved names: aytm_response_id, uuid, var1, var2, var3, device, browser, vr_collected, gender, income, education_level, age, children, relationship_status, ethnicity, employment, career, show, hide, group, if, not, max, or, and, exclude, exit, region, country, state, county, and zip. Also no variables can start with letter Q# (followed by a number) or letters PQ# (followed by a number), as they are reserved for direct references.
You can show respondent the value of any variable by surrounding its name in square brackets. For example,
- [QuizScore] - From the example above, will show respondent the score they've achieved by the time they enter the field.
You may also want to use this method to see the value of a variable during survey programming process to check that everything works as expected and then remove it before launching if you don’t want respondents to see it.
Furthermore, you can use one of the reserved variable names in square brackets to pipe in their value: uuid, var1, var2, var3, device, browser, gender, income, education_level, age, children, relationship_status, ethnicity, employment, career, region, country, state, county, and zip. For example, you can type in the following Question: "We've noticed that you're using [device] to take this survey. Is this correct?". Respondent, answering on an iPhone will see: "We've noticed that you're using mobile to take this survey. Is this correct?"
Var1, var2, and var3 can be mapped to give you access to any custom variables you are passing through the URL when using list surveys.
Variables will be initialized and updated when respondent exits the question, so you can't rely on a manipulation with the variable within a question until they've made their choice and moved to the next one.
Supported list of operations with aytm Logic:
- Addition [result = 36 + 7]
- Subtraction [result = 36 - 7]
- Multiplication [result = 36 * 7]
- Division (expect floating-point values) [result = 36 / 7]
- Exponentiation [result = 36 ** 3] [result = 36 ^ 3]
- Exponentiation of Euler's number (expect floating-point values) [result = exp 3]
- Concatenation (for strings) [result = "Promoter " + "and influencer"]
- Rounding a number: [result = round 3.1415] will result in 3
- Rounding a number to a specific decimal place: [result = round2 3.1415] will result in 3.14
- Rounding up a number: [result = ceil 3.1415] will result in 4
- Rounding up a number to a specific decimal place: [result = ceil3 3.1415] will result in 3.142
- Rounding down a number: [result = floor 3.1415] will result in 3
- Rounding down a number to a specific decimal place: [result = floor1 3.1415] will result in 3.1 and is compatible with floating point numbers [z = 0.1 + 1.1 + .1]