Understanding Post-Messages: How to Interact with the Widget

Last updated October 10th, 2025

Post-messages are a powerful way to connect your website with the questionnaire. They allow you to capture user interactions—like adding products to cart or saving matches—and trigger custom experiences, all without touching the embedded widget itself.

When a user engages with the questionnaire on your site—completing it, browsing product matches, or saving preferences—the widget can send structured messages back to your site using postMessage events. These post-messages act as secure signals from the embedded iframe, giving you real-time access to valuable data and user actions.

You can use these messages to:

  • Automatically add matched products to your cart or wishlist

  • Store completed profiles for later use

  • Track questionnaire progress and completion

  • Display personalized results on product detail pages

  • Trigger custom UI behaviors or analytics events

All communication is safely scoped to trusted origins and designed for seamless integration. With just a few lines of JavaScript, you can tailor the customer journey to fit your brand—while making the most of the data and personalization our solution delivers.

In the guide below, we’ll walk you through the full list of available post-messages, what they include, and how to use them in your implementation.

Available postMessage Events from SMT

  1. User Profile JSON

    if ('smt-profile-json' in e.data)
    
    • Purpose: Contains the user’s full profile after questionnaire completion.

    • Data: smt-profile-json (object)

  2. Add to Cart

    if (e.data.action == "add-to-cart")
    
    • Purpose: Instructs your site to add a product (or routine) to the cart.

    • Data: ean (can be single or comma-separated list)

  3. Add to Wishlist

    if (e.data.action == "add-to-wishlist")
    
    • Purpose: Indicates user added product to wishlist.

    • Data: ean (single)

  4. Remove from Wishlist

    if (e.data.action == "remove-from-wishlist")
    
    • Purpose: Indicates user removed product from wishlist.

    • Data: ean (single)

  5. Matching Results

    if (e.data.action == "smt-matching-results")
    
    • Purpose: Returns matches per product group after questionnaire.

    • Data:

      • group (product group)

      • results (array of matched products with metadata)

  6. Next Slide

    if (e.data.action == "next-slide")
    
    • Purpose: Triggered when user moves to the next questionnaire slide.

    • Data: slideIndex

  7. Previous Slide

    if (e.data.action == "previous-slide")
    
    • Purpose: Triggered when user moves to the previous slide.

    • Data: slideIndex

  8. Goto Slide

    if (e.data.action == "goto-slide")
    
    • Purpose: Triggered on any slide change (via nav, progress bar, arrows).

    • Data: slideIndex

  9. Finish Questionnaire

    if (e.data == "smt-finish-questionnaire")
    
    • Purpose: Indicates the questionnaire is complete.

    • Data: (string match only)

Notes for Implementation

  • ean values can be a single string or a comma-separated list, depending on the action (add-to-cart especially).

  • You can extend your site logic at each of these touchpoints to sync with carts, analytics, or UI changes.

Related Topics