Conditions within Kinesis are code-based logic statements. For the following types, these either evaluate to TRUE or FALSE:
- Display Conditions
- If it returns TRUE, the element is displayed. If it returns FALSE, the element is hidden or bypassed.
- Validation Conditions
- If it returns TRUE, the validation message is triggered.
- Quota Filter Conditions
- If it returns TRUE, it increments the quota count.
For the following remaining logic types, these should be returning a response value:
- Default Answer Conditions
- Used to prepopulate a question response. Accepts a value corresponding to the question type.
- Computational Questions
- Hidden datapoints consisting only of computational logic for the purpose of returning a response.
1: Using the Condition Editor
The Condition Editor popup is used for inserting conditions onto individual survey elements. You can use the provided pulldowns for building simple conditions based upon previous question responses or you can write custom conditional logic into the textbox provided. See below for help writing your own conditional logic statements.
1.1: Copy & Pasting Conditions
Within the Survey Editor, you can now batch update conditional syntax for each question by expanding (-) the desired question. From there, you can utilize our traditional condition editor or simply copy and paste a longer, preformatted set of conditions.
2: Display Conditions
These are conditional statements placed onto survey elements to control whether the element is displayed or bypassed. If the conditional statement returns TRUE, the element is displayed. If it returns FALSE, the element is bypassed or hidden. Display conditions may be inserted for the following survey elements:
- Question choices
- Table rows and columns
Display conditions are typically added by clicking the icon anywhere in the Survey Editor, which will bring up the Condition Editor.
To place a condition on an option within a question, you will first need to display those options, as shown below or click to edit the question properties. Click on the [+] sign to display all of the options in the Survey Editor.
3: Conditional Logic Syntax
Conditional statements consist of a single or multiple comparison operators and, depending on previous answers, the comparison results of the statement are either true (satisfied) or false (dissatisfied). The question variables are the same as the question labels you use in your survey. Every question variable starts with a $ sign (e.g. $Q1, $Qname). See PHP Functions for a full list of available PHP functions available in Kinesis.
3.1: Comparison Operators
Any of the following symbols may be used in formulating conditional statements:
== equals != not equals < smaller than > greater than <= smaller than or equal to >= greater than or equal to
3.2: Logical Operators
The following may be used as logical operators to connect strings of conditional statements:
AND or && OR or ||
TIP: Remember to use parentheses with certain logical operators (such as the example below, where respondents prefer ice cream with selected flavors).
$Q1=="icecream" AND ($Q2=="vanilla" OR $Q2=="chocolate")
3.3: Radio and Pulldown
Radio and Pulldown values can be checked directly from the question variable.
$Q1==1 $Q1!=1 $Q1>1 $Q1>=1 $Q1<5 $Q1<=5
3.4: Text and Textarea
Text and textarea values can be checked directly from the question variable.
Number values can be checked directly from the question variable.
$Q1==43 $Q1!=20 $Q1>1000
Checkbox questions utilize slightly different logic because each answer can contain multiple checked choices. When creating conditions for values in multiple choice (checkbox) questions you also need to specify which choice you are comparing in brackets. The checkbox choice number or ID is placed in square brackets immediately following the question variable. For example, selecting Q12 choice number 4 would be represented as $Q12. Checkbox choices are 1 when checked and 0 unchecked. Therefore, to test if Q14 choice 4 was checked you would write $Q14==1 (indicates the item was selected) or unchecked $Q14==0 (indicates the item was not selected).
Testing if checkbox choices were selected (Q2 choice 2 checked AND choice 3 unchecked):
$Q2==1 AND $Q2==0
More than two options were checked:
The 1 after the comma signifies the options that were checked, also noted as the 1 after the "==" in the standard checkbox conditioning, ie $Q1==1.
Values on ranking questions are tested the same way as checkbox (multiple choice) questions. However, the first selected choice is designated as option 1, the second selected choice is designated as option 2, and so forth.
3.7.1: Checking for the ranked position of an option choice
The first item was ranked in the first position:
The first item was ranked in the third position:
The third item was ranked in any position:
Remember that when writing validations or conditional statements on ranking questions that you specify a minimum number of choices that is less than what are you intending to test. If your minimum number of ranking items is set to 2, never try to test index 3 $Q1 because there will most likely be a respondent who only ranks the
bare minimum required.
3.7.2: Checking for the total count of ranked items
To get the count of items ranked:
3.8: Card sort
Similar to checkbox or ranking questions, card sort values are stored into arrays, however they are stored as multi-dimensional arrays, or an array within an array.
The first card was sorted into any category:
The first card was sorted into the second category:
More than 2 cards were sorted into the third category:
Checks whether the fourth and fifth cards were sorted into the same category:
Each part of date questions are accessible by using the following standard format.
Example Date: 01/15/2014 OR 2014/01/15 (and other formats)
Accessing year :
Accessing month :
Accessing day :
Slider values can be checked similarly to number questions, however their values are stored into an array because if using a "dual" slider, their may be two values recorded. For "dual" sliders, the minumum value is stored as the first array position (ex. $Qslider). The maximum value, or the value for a "single" slider is stored in the second array position (ex. $Qslider).
Single slider value is exactly 50:
Single slider value is greater than or equal to 20:
Dual slider min value is less than 0 AND max value is greater than 10:
$Q1<0 AND $Q1>10
4: Creating Conditions with URL Variables
Any URL parameter values contained on the incoming link can be referenced using the syntax $IN_[parameter name]. The following conditions could be written in reference to the example incoming link:
$IN_name=="John" if ($IN_source==1) return "Sample A"; else return "Sample B";
Notice: A system message error will be generated if a condition references a parameter not found on the incoming link. Therefore if the incoming parameter is optional, you can check whether it is set, using php function isset(), before using it in your logic. For example:
isset($IN_source) AND $IN_source==1 if (isset($IN_name)) return $IN_name; else return false;
5: Available Session Variables
The $SESSION variables are system data that can be used within Kinesis Survey to create conditions and/or default answers. To reference a session variable, use syntax $SESSION['PARAM'], where PARAM is the parameter name. Available $SESSION variables:
5.1: Session ID
An incremental session id, unique to each session.
sessionid => 11
5.2: Session String
Session code, unique to each session. This string can be used to resume a survey.
sessionstr => c7a8e237
5.3: Respondent ID
An incremental respondent id (RID), unique to each respondent.
respondentid => 4
Unique respondent identifier associated with the session. Must be appended to invitation URL with IDENTIFIER=xxx or preloaded via the Respondent Manager.
identifier => K_bb912aac3c424a3d
5.5: Survey ID
The survey or project ID as it is displayed on the Project Selection screen.
surveyid => 140
5.6: User Agent
Stores the respondent's user agent. This provides you with the browser/OS/device being used.
agent => Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:126.96.36.199) Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729; .NET4.0C)
5.7: Panel Session Key
Unique session code from Kinesis Panel. Used for invitation links.
panel_sesskey => ks
5.8: IP Address
IP Address for the respondent. This is recorded when the session is created.
ipaddress => 192.168.0.70
5.9: Test Condition
Allows you to create test-only conditional statements, very helpful to display backend data for Test Runs & Links.
testrun => no
5.10: Mobile Condition
Specifies if a session is mobile. Allows you to create mobile-only conditionals for respondents.
mobile => no
5.11: Local ID
Code to specify the language used to take the survey. Corresponds to IDs in the Language Manager, default is 1.
localid => 1
5.12: Referer Link
Contains the web address of the site that referred the respondent to the survey.
referer => http://www.domain.com
5.13: Request Incoming URL Parameters
Stores incoming URL parameters from respondent invitation.
request => /surveyinstall/html.pro?ID=1
Used for Exit Pages. Must be included on invitation link.
pcid => ks
5.15: Markup Type
HTML markup type used to display survey content. Default for desktop/laptop surveys is HTML.
markup => html
5.16: Page Number
Current page number. Starts at 0 and increments by one with each page submission.
pagenum => 1
5.17: Last Seen
Timestamp for last known access or activity within the survey. Example: $SESSION['lastseen']
lastseen => 2010-07-21 12:14:27
5.18: Creation of Session
Timestamp for creation of user session.
5.19: Expiration of Session
Timestamp for when the user session expires. This is based on the expiration limit set within Survey Properties. Default value is one year. Example: $SESSION['expires']
expires => 2013-04-16 12:14:27
5.20: General Examples
Respondent is using the second uploaded language:
System has detected that respondent is accessing from a mobile device:
System has detected that respondent is accessing from a mobile device with HTML5 support: