Skip to content

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.

Wrap any variable name in percent signs:

feedback = You responded in %RT% ms.

At runtime Testable replaces %variable% with the actual value.

These are populated automatically from the current trial’s outcome:

VariableValue
%response%Participant’s response (text or button label)
%RT%Reaction time in milliseconds
%correct%1 if correct, 0 if not

Reference outcomes from earlier trials:

VariableRetrieves
%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

Compute a summary statistic over a range of past trials:

Syntax: %variable.function[range]%

FunctionResult
meanArithmetic mean (avg is a synonym)
modalMode
sumSum
minMinimum
maxMaximum
countCount of 1 values (e.g. number correct)
percPercentage of 1 values (useful for accuracy)
FormatMeaning
[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]% ms
feedback = Accuracy: %correct.perc[-49_0]%%
feedback = You got %correct.count[1,2,3,4,5]% of 5 correct.

These are automatically populated from the participant details form (if enabled):

VariableValue
%id%Participant ID
%gender%Gender
%age%Age
%education%Education level
%handedness%Handedness
%nationality%Nationality
%customvar1%First custom variable

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.

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=M1234

This is useful when your external platform expects specific values in the URL path rather than as query parameters.

To define your own variables or build lists during the experiment, see Scripts.