labvanced logoLabVanced
  • Research
    • Publications
    • Researcher Interviews
    • Use Cases
      • Developmental Psychology
      • Linguistics
      • Clinical & Digital Health
      • Educational Psychology
      • Cognitive & Neuro
      • Social & Personality
      • Arts Research
      • Sports & Movement
      • Marketing & Consumer Behavior
      • Economics
      • HCI / UX
      • Commercial / Industry Use
    • Labvanced Blog
    • Services
  • Technology
    • Feature Overview
    • Code-Free Study Building
    • Eye Tracking
    • Mouse Tracking
    • Generative AI Integration
    • Multi User Studies
    • More ...
      • Reaction Time/Precise Timing
      • Text Transcription
      • Heart Rate Detection (rPPG)
      • Emotion Detection
      • Questionnaires/Surveys
      • Experimental Control
      • Data Privacy & Security
      • Desktop App
      • Mobile App
  • Learn
    • Guide
    • Videos
    • Walkthroughs
    • FAQ
    • Release Notes
    • Documents
    • Classroom
  • Experiments
    • Cognitive Tests
    • Sample Studies
    • Public Experiment Library
  • Pricing
    • Licenses
    • Top-Up Recordings
    • Subject Recruitment
    • Study Building
    • Dedicated Support
    • Checkout
  • About
    • About Us
    • Contact
    • Downloads
    • Careers
    • Impressum
    • Disclaimer
    • Privacy & Security
    • Terms & Conditions
    • Third-Party Licenses
  • Appgo to app icon
  • Logingo to app icon
Learn
Guide
Videos
Walkthroughs
FAQ
Newsletter Archive
Documents
Classroom
  • 中國人
  • Deutsch
  • Français
  • Español
  • English
  • 日本語
Guide
Videos
Walkthroughs
FAQ
Newsletter Archive
Documents
Classroom
  • 中國人
  • Deutsch
  • Français
  • Español
  • English
  • 日本語
  • Guide
    • GETTING STARTED

      • Task Editor
      • Frames
        • Canvas Frame
        • Page Frame
        • Website Frame
      • Trial Timeline
      • Stimulus Presentation
      • Correctness of Response
      • Objects
      • Events
      • Variables
      • Task Wizard
      • Trial System
      • Experiment Design
        • Creating a Study
        • Data Frame Patterns
        • Multi-user Experiment Design
        • Longitudinal Experiment Design
    • FEATURED TOPICS

      • Randomization & Balance
      • Eye Tracking
        • Presenting Stimuli in an Eye Tracking Task
        • How to Choose Eye Tracking Calibration Settings
        • Setting Up Eye Tracking in a Task
        • Recording and Exporting Gaze Data
        • Using Shapes as Areas of Interest (AOI) for Eye Tracking
        • The Participant Calibration Experience
      • Web Bridge
        • Selecting Website AOIs | Anchor, Adjust, and Verify AOI Tracking
        • Tracking Mouse Behavior on a Website AOI | Web Bridge Guide
      • Questionnaires
      • Desktop App
      • Sample Studies
      • Participant Recruitment
      • API Access
        • REST API
        • Webhook API
        • WebSocket API
      • Other Topics

        • Precise Stimulus Timings
        • Multi User Studies
        • Head Tracking in Labvanced | Guide
    • MAIN APP TABS

      • Overview: Main Tabs
      • Dashboard
      • My Studies
      • Shared Studies
      • My Files
      • Experiment Library
      • My Account
      • License & Services
    • STUDY TABS

      • Overview: Study-Specific Tabs
      • Study Design
        • Tasks
        • Blocks
        • Sessions
        • Groups
      • Task Editor
        • Task Controls
        • The Trial System
        • Frame Types
        • Objects
        • Object Property Tables
        • Variables
        • System Variables Table
        • The Event System
        • Text Editor Functions
        • Eye Tracking Options in the Task Editor
        • Head Tracking in a Task
        • Multi-User Studies
      • Settings
      • Variables
      • Media
      • Texts & Translate
      • Launch & Participate
      • Subject Management
      • Dataview and Export
        • Dataview and Variable & Task Selection (OLD Version)
        • Accessing Recordings (OLD Version)
  • Videos
    • Video Overview
    • Getting Started in Labvanced
    • Creating Tasks
    • Element Videos
    • Events & Variables
    • Advanced Topics
  • Walkthroughs
    • Introduction
    • Stroop Task
    • Lexical Decision Task
    • Posner Gaze Cueing Task
    • Change Blindness Flicker Paradigm
    • Eye-tracking Sample Study
    • Infant Eye-tracking Study
    • Attentional Capture Study with Mouse Tracking
    • Rapid Serial Visual Presentation
    • ChatGPT Study
    • Eye Tracking Demo: SVGs as AOIs
    • Multi-User Demo: Show Subjects' Cursors
    • Gamepad / Joystick Controller- Basic Set Up
    • Desktop App Study with EEG Integration
    • Between-subjects Group Balancing and Variable Setup
    • Building a Multi-user Study
    • Website Frame Eye Tracking Walkthrough
    • Conditional Webcam Eye Tracking
  • FAQ
    • Features
    • Support Policy & Guidelines
    • Security & Data Privacy
    • Licensing
    • Precision of Labvanced
    • Programmatic Use & API
    • Using Labvanced Offline
    • Troubleshooting
    • Study Creation Questions
  • Newsletter Archive
  • Documents
  • Classroom
Set / Record Variable action writing a new value into a variable in Labvanced

Set / Record Variable Action

The Set / Record Variable action writes a value into a variable the moment the event containing it fires. It sits in the Variable Actions category of the event system, and it is the single most common action in Labvanced: almost every recorded behavioral measure and almost every variable-driven condition in a study passes through it at some point.

Table of Contents

  • Overview
    • Common Use Cases
  • Required Background Knowledge
  • How It Works
  • Workflow Tips
  • Studies & Example Scenarios
  • Further Reading and Open Materials

Overview

Once a variable exists, Set / Record Variable is how it actually gets a value: a reaction time, a participant's choice, a running score, a coordinate pair from a mouse movement. Without it, a variable stays at its start value for the whole study.

Location of the Set / Record Variable action in the Labvanced events menu

Locating Set / Record Variable under Variable Actions in the events menu.

Common Use Cases

Set / Record Variable shows up across almost every category of study, from simple button-press tasks to full physiological recordings.

  • Recording a behavioral measure: save a reaction time, an accuracy score, or a typed response into a variable so it appears in the exported data.
  • Building a counter: increment a variable by 1 each time a trigger fires, to count trials completed, errors made, or button clicks.
  • Capturing trigger-specific values: write values a trigger provides, such as mouse X/Y coordinates or a gaze position, directly into a variable.
  • Driving conditional logic: set a variable that a later Requirement Action checks to decide which branch of the study runs next.

Required Background Knowledge

Before diving into this action, it's recommended to understand the basic functionalities of variable creation and their properties, as described in these pages:

Creating Variables

The different ways to create a variable in Labvanced, from the Variables tab, the task editor, an object prompt, or the event system.

Variable Properties

The settings that define a variable: name, data type, scale, and the record variable toggle.

How It Works

To access Set / Record Variable, open the Event System in the Task Editor and create a new event. Under Add Action → Variable Actions, select Set / Record Variable.

A simple dialog appears with two parts, read as an equation:

Set / Record Variable dialog box in Labvanced

The Set / Record Variable dialog box: the target variable on the left of the equals sign, its new value defined on the right.
OptionDescription
Select (green button)Choose the variable that should store the value, on the left of the equals sign. You can also create a new variable here without leaving the dialog.
Pen iconOpens the Value Select Menu, on the right of the equals sign, to define what the new value actually is: a constant, another variable's current value, a trigger-specific value, or an arithmetic expression.

That's the whole action: pick a variable, define its new value, done. The dialog also shows a fixed line, "Recordings will take place at the end of the trial": the variable's value updates on the client immediately when the action runs, but that value is only sent to the server and recorded at the end of the trial, not on every individual change.

A practical scenario: building a counter. There is no special "counter" variable built into Labvanced, any variable can act as one. Create a numeric variable with whatever name fits your study (for example trial_count or error_count), then use the Value Select Menu's Arithmetic option to set that variable's new value to itself plus one, each time the relevant trigger fires. This is the same mechanism behind trial counters, error counters, and click counters across Labvanced tasks, so it's important to understand how such a setup works in order to get a sense of the capabilities behind this action.

In some cases, while building your task, you may be prompted with a dialog box asking if you want events created automatically to capture certain types of data, such as eye tracking. Accepting this builds both the trigger and a Set / Record Variable action for you, already configured, the exact same action and dialog covered above.

Eyetracking Setup dialog offering to automatically add gaze and fixation recording events, and the resulting Set / Record Variable action it creates

Accepting the Eyetracking Setup dialog's offer to add gaze and fixation events creates a Set / Record Variable action automatically.

Set / Record Variable action configured to increment a counter variable by 1 in Labvanced

Setting a counter variable to itself plus 1 using Set / Record Variable.

Workflow Tips

  • Plan your variables before you build: before starting to build, make sure you know all the data you need to capture in your study, and have a general idea of which variables will need to be created to store that data. Set / Record Variable is where that plan gets executed, so deciding it upfront avoids restructuring events mid-build.
  • Reuse a similar action instead of rebuilding it: if you already have a similar Set / Record Variable action under the same trigger or elsewhere in the study, use Copy to Clipboard and paste it where needed, then edit the target variable or value slightly, rather than clicking through Select and the Value Select Menu again from scratch.
  • Group actions that belong together: if multiple Set / Record Variable actions typically go together, plan your event design around an Action Group that houses them. Moving or copying the whole set later is faster than handling each action individually.
  • Check for Automated Event Setup first: in some cases, such as eye tracking, emotion detection, or heart rate, Labvanced can offer to build the trigger and its Set / Record Variable action for you. Check whether that dialog is available before setting the same thing up by hand.

Studies & Example Scenarios

Two real examples from published Labvanced tasks, one scoring a single response and one recording continuous movement.

Scoring accuracy in the Flanker Task

In the Flanker Task's Main_task_desktop_Flanker task, Frame 3 (Response Window), a Requirement Action inside the Response Recording & Progression event checks whether the pressed key matches the target direction. When it does, Set / Record Variable sets the accuracy variable to 1.

Recording mouse trajectory data

The Web Bridge mouse-tracking setup uses Set / Record Variable to write the Mouse [Name, Info, X, Y] Array trigger-specific value into a variable on every mouse movement. It sets Format to Array, Record Type to Time series, and Sampling method to record all (allow repeated duplicates), so every movement is captured rather than just the latest one.

Further Reading and Open Materials

Illustration of the event system in Labvanced, the full reference for every trigger and action

Event System

The full reference for every trigger and action in Labvanced.

Value Select Menu

How to define constants, variables, trigger-specific values, and expressions as the value assigned by this action.

Requirement Action (If... Then... Else If)

The conditional logic block that most commonly triggers Set / Record Variable inside its Then and Else branches.

Creating Variables

How to create a variable and set its data type, format, and recording options before or while using this action.