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
      • Stimulus Presentation
      • Correctness of Response
      • Objects
      • Events
      • Variables
      • Task Wizard
      • Trial System
      • Study Design
        • Tasks
        • Blocks
        • Sessions
        • Groups
    • FEATURED TOPICS

      • Randomization & Balance
      • Eye Tracking
      • 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
        • Canvas and Page Frames
        • Objects
        • Object Property Tables
        • Variables
        • System Variables Tables
        • The Event System
        • Text Editor Functions
        • Eyetracking in a Task
        • 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
  • 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

PostMessage Received Trigger

The PostMessage Received trigger fires when your running Labvanced experiment receives an incoming message from an external source via the browser's postMessage API. Use it to connect your study to a parent webpage, a custom application, or an embedded external website that sends data directly into the experiment.

Table of Contents

  • Overview
  • The Two-Sided Setup
  • How it works
  • Trigger Options
  • Trigger-Specific Values
  • Further Reading and Open Materials

Overview

The PostMessage Received trigger can be found listed under the API/External Trigger in the trigger selection menu.

Selecting the PostMessage Received trigger from the API/External Trigger category in the Labvanced event editor.

Locating the PostMessage Received trigger under API/External Trigger in the event editor.

Common use cases

  • An embedded website forwarding user interaction events (clicks, form completions) into Labvanced as structured postMessages.
  • A parent application (e.g., a custom LMS or institutional web portal) sending a message to advance the experiment or pass in participant data.
  • A JavaScript-driven integration where an external script triggers a specific point in the experiment logic.

The Two-Sided Setup

Using postMessage between Labvanced and an external page (such as an iFrame or a parent application) is a two-sided process. Labvanced handles one side: this trigger listens for incoming messages. The other side is the external page, which must be programmed to send those messages.

The postMessage API is a standard browser feature. The external page calls window.parent.postMessage(data, targetOrigin) to send data to Labvanced. You or your developer will need to write that code. An AI coding tool can also help you set this up by giving it the context and generate it quickly if needed.

A common pattern is for the external page to listen for its own user events (such as clicks, form submissions, or sign-ups) and then forward each one as a postMessage to Labvanced. Each event type can be tagged with a label (e.g., click_event, signup_event) using the Key field, so Labvanced can filter and respond to each one separately with its own event.

How it works

When the experiment is running, Labvanced listens for incoming postMessages. Every time a message arrives, it checks two things:

  • Origin Domain: does this message come from an allowed source?
  • Key: does this message carry the expected key value (if one is set)?

If both conditions are met, the trigger fires and the message payload becomes available as Message Content in your actions.

The external page is responsible for sending the messages. It does this by calling window.parent.postMessage(data, targetOrigin) in its own code. The data it sends can be anything: a plain string, a structured value, or an event label. The Key field in Labvanced is how you match on a specific value of that label to distinguish one type of message from another.

Each message type can have its own dedicated event in Labvanced. For example, one event uses Key: click_event to fire when the external page reports a click, and another uses Key: signup_event to fire when it reports a form submission.


Upon selecting PostMessage Received, the following dialog will appear:

The PostMessage Received trigger configuration dialog in Labvanced, showing Origin Domain and Key fields.

Configuration options for the PostMessage Received trigger. The incoming message value will be exported as Message Content.

Trigger Options

Menu ItemPostMessage Received Trigger Options
Origin DomainSpecifies which domain is allowed to send messages to this trigger. The default value is *, which accepts messages from any origin. To restrict the trigger to a specific source, replace * with the full origin URL (e.g., https://yoursite.com). This is recommended whenever the sending source is known.
KeyEnter the specific key value you want this trigger to match (e.g., click_event, signup_event). The trigger will only fire when an incoming message carries that exact key value. Leave the field empty to fire on any incoming message, regardless of content.

Note: The incoming message value will be exported as Message Content and can be referenced in actions via the Value-Select Menu.


Trigger-Specific Values for PostMessage Received

After selecting the PostMessage Received trigger, you can reference the following trigger-specific values in subsequent actions via the Value-Select Menu.

ValueDescription
Message ContentThe data payload of the received postMessage. This is the value sent by the external source and can be stored in a variable, used to drive logic, or recorded as part of your dataset.
Trigger Timestamp (Unixtime)The timestamp of when the trigger fired, in Unixtime.
Trigger Time (From Frame Onset)Time in milliseconds from the start of the current frame to when the trigger fired.

Further Reading and Open Materials

  • Send PostMessage Action: the paired action for sending a message back to an external source.
  • Value-Select Menu: how to reference trigger-specific values in your actions.
  • Events Overview: a full introduction to the trigger-and-action logic system in Labvanced.