Variable manager

Introduction

The Variable manager allows you to create and manage survey variables.

Variables are containers that store information. In common scripting languages, variables can be configured to calculate, combine and/or store just about any type of information you can think of.

There are two ways to access the Variable manager:  

  1. While on the Create tab (1), open the Tools dropdown and click the Variable manager option (2).
    Image calling out the steps to find the variable manager in Discover
  2. While on the Share tab (1), look at the bottom of the screen in the Variables section (2). This is a replica of the table in the Variable manager.
    Image highlighting the steps to find the variables area on the Share Page

Creating a variable

  1. Click the + Add variable button at the bottom of the variables table.
  2. Give the variable an appropriate name and then defocus the Name input field (click anywhere outside of the field). This saves the variable to a new column in the survey database with the same name that you provide here.
Create Variable

Reserved words

In Discover, variables are created using JavaScript, which means you must follow JavaScript’s naming rules. This includes avoiding the use of "reserved words," which are terms that have special meanings in JavaScript, often linked to functions or other language features.

To prevent unintentional overwriting of predefined functions, we’ve expanded the set of reserved words in Discover. It's important to avoid using these reserved words as variable names, as doing so will make your script invalid. If a reserved word is used, an error will appear in the survey audit, and the survey will not be able to be published.

For a complete list of JavaScript's reserved words, refer to this article. You can also review articles on predefined functions to identify which functions are considered reserved words in your survey.

Variable settings

There are various settings that can be applied to a variable.

Include in URL

This setting allows variables to be used as pass-in variables, which accept values passed through the survey link (URL) for each respondent. The data passed into a variable is stored as a new value in the survey database. While any variable can be included in the URL, a variable marked as a Unique ID must be included if used in the survey. Additionally, for multi-language surveys, the language can be specified in the URL via the Languages page.

Pass-in variables are especially useful for directing respondents from one survey or platform to another while retaining key data, such as respondent ID, age, or location.

For a step-by-step guide on survey linking and passing data, see our article on Linking surveys and passing data.

After a Pass-in variable is saved, it is appended to the survey link in the Share tab. Replace the XXXX placeholder with the desired values to pass data into the survey. The variables will not be available in the live survey link until you publish your survey. Any changes will require republishing.

Survey example link image

 

Unique ID

For each respondent who takes a survey, Discover automatically generates a 24-character unique identifier known as a Record ID. You can create your own identifier variable in the Variable manager. Similar to the Record ID, this new variable must be unique for each respondent. Only one variable can be designated as the unique ID.

Using a unique ID has several benefits:

  • It enables respondents to resume the survey if they leave and return, provided they use the same link with the original unique ID value.
  • It facilitates identifying respondents during data cleaning processes.
  • It allows for tracking respondents across different platforms or sample providers, enabling data to be passed back and matched based on this variable.

While Record IDs and Unique IDs are functionally similar, unique IDs offer the flexibility of using custom values that can be defined before respondents take the survey. This feature allows respondents to continue their survey progress even if they leave and return.

Consider this data table. It is an example of a survey data export that includes three variables:

Record ID country name
83f0d5 uk beverly
be5bf2 uk chet
ef93dc australia betty
b4j2ms usa leon

Record ID: automatically assigned to every respondent, ensuring each survey record is unique.

Country: variable created by the survey author; it has not been marked as unique, therefore multiple respondents can be assigned the same values (uk was given to two respondents).

Name: variable created by the survey author; it has been marked as unique. Every respondent will have a unique value assigned by the survey author or panel provider.

The first respondent would be given a link such as:

https://surveys.sawtoothsoftware.com/83f0d5?country=uk&name=skyler

This link allows the respondent to enter, exit, and return to the same survey. As survey authors, we can use the value "skyler" to locate their record in the dataset.

For a more in-depth tutorial on survey linking (passing respondents and data in or out of a survey), see our linking in and out of surveys article.

Variable type

The Variable type setting specifies whether the variable stores Text or Number data.

It’s important to set the appropriate data type because it influences how each variable is interacted with and handled in survey authoring, data collection (recording), and analysis.

Consider the following descriptions when choosing between Variable types.

Text variables

Text variables are the most versatile and flexible data type, which makes them the default setting for new variables. If you are unsure which type to select, Text is the safest choice.

Regardless of whether the value contains letters, numbers, or a combination, they are always stored as text.

Text variables are treated as categorical data: using categorical operations in logic building/scripting and available in analysis for Crosstabs and segmentation.

Important note: Text variables are not compatible with mathematical operators in logic building and scripting, even if the value is comprised of solely numbers.

Number variables

Numeric variables are specifically designed for storing and handling numeric data.

Consequently, Numeric variables are compatible with mathematical operations in logic building/scripting though they are not available in Crosstabs or segmentation in analysis.

Important note: Numeric variables are not allowed as Pass-in variables or Unique IDs.