Using Variables
Experiments Surveys & forms
Variables let you embed dynamic content anywhere in your trial file (feedback text, instructions, stimulus text, or form questions) by using the %variable% placeholder syntax.
Syntax
Section titled “Syntax”Wrap any variable name in percent signs:
feedback = You responded in %RT% ms.At runtime Testable replaces %variable% with the actual value.
Built-in response variables
Section titled “Built-in response variables”These are populated automatically from the current trial’s outcome:
| Variable | Value |
|---|---|
%response% | Participant’s response (text or button label) |
%RT% | Reaction time in milliseconds |
%correct% | 1 if correct, 0 if not |
Historical trial variables
Section titled “Historical trial variables”Reference outcomes from earlier trials:
| Variable | Retrieves |
|---|---|
%response3% | Response from trial file row 3 |
%response-1% | Response from the previous trial |
%response[trialA]% | Response from the trial with label = trialA |
%correct[trialA]% | Correct/incorrect from labelled trial |
%RT3% | RT from trial file row 3 |
Aggregate statistics
Section titled “Aggregate statistics”Compute a summary statistic over a range of past trials:
Syntax: %variable.function[range]%
Functions
Section titled “Functions”| Function | Result |
|---|---|
mean | Arithmetic mean (avg is a synonym) |
modal | Mode |
sum | Sum |
min | Minimum |
max | Maximum |
count | Count of 1 values (e.g. number correct) |
perc | Percentage of 1 values (useful for accuracy) |
Range formats
Section titled “Range formats”| Format | Meaning |
|---|---|
[2,3,4] | Specific trial rows |
[-4_0] | Last 5 trials (relative; 0 = current) |
[-9_-5] | Trials from 10 back to 6 back |
Examples:
feedback = Mean RT over last 10 trials: %RT.mean[-9_0]% msfeedback = Accuracy: %correct.perc[-49_0]%%feedback = You got %correct.count[1,2,3,4,5]% of 5 correct.Participant details variables
Section titled “Participant details variables”These are automatically populated from the participant details form (if enabled):
| Variable | Value |
|---|---|
%id% | Participant ID |
%gender% | Gender |
%age% | Age |
%education% | Education level |
%handedness% | Handedness |
%nationality% | Nationality |
%customvar1% | First custom variable |
URL parameter variables
Section titled “URL parameter variables”Parameters passed in the experiment URL are automatically available as variables and are forwarded to outgoing redirect URLs. For example, if the experiment URL includes ?participant=P001, you can use %participant% in your content.
Path variables
Section titled “Path variables”You can also embed variables directly in URL path segments, not just query parameters. For example:
https://example.com/%age%/%nationality%/?id=%id%If a 29-year-old participant from Chile with ID M1234 completes the study, the redirect URL becomes:
https://example.com/29/Chile/?id=M1234This is useful when your external platform expects specific values in the URL path rather than as query parameters.
Defining your own variables
Section titled “Defining your own variables”To define your own variables or build lists during the experiment, see Scripts.
Next steps
Section titled “Next steps”- Feedback: use variables in feedback text
- Generating Questions from Lists: use lists with variable syntax
- How to Inject Logic: use response values in conditions