Skip to main content
TriggerConfig is exported from the package and can be imported. The other types on this page (PopupTriggerType, PopupTriggerCondition, PopupTrigger) are used internally and documented here for reference.

TriggerConfig

Options for configuring survey triggers.
export interface TriggerConfig {
    type: 'time' | 'scroll' | 'exit' | 'click' | 'event';
    value?: number | string;
    surveyId: string;
    popupId?: string;
}

Parameters

type
'time' | 'scroll' | 'exit' | 'click' | 'event'
required
Trigger type:
  • time: Delay trigger (milliseconds)
  • scroll: Scroll percentage trigger
  • exit: Route exit trigger
  • click: Element click trigger (by id)
  • event: Custom host event trigger
value
number | string
Value for the trigger:
  • time: milliseconds to wait
  • scroll: scroll percentage (0-100)
  • exit: seconds before route exit
  • click: element id to watch
  • event: custom event name
surveyId
string
required
Survey ID to show when triggered
popupId
string
Optional popup definition id (used to disambiguate repeated survey ids)

PopupTriggerType

Specific trigger type for remote popup definitions.
export type PopupTriggerType = 'time_on_page' | 'scroll' | 'exit' | 'click' | 'event';

Trigger Types

time_on_page
string
Trigger after user has been on page for a specified duration
scroll
string
Trigger when user scrolls to a specific percentage of the page
exit
string
Trigger when user attempts to exit or navigate away from the page
click
string
Trigger when user clicks a specific element
event
string
Trigger on a custom event dispatched by the host application

PopupTriggerCondition

Additional condition for popup activation.
export interface PopupTriggerCondition {
    answered: boolean;
    cooldownDays: number;
}

Properties

answered
boolean
required
Whether the user has already answered the survey. If true, the popup will not be shown (unless cooldown has expired)
cooldownDays
number
required
Number of days to wait before showing the popup again after user interaction

PopupTrigger

Trigger associated with popup definition (used in PopupDefinition).
export interface PopupTrigger {
    type: PopupTriggerType;
    value: number | string;
    condition?: PopupTriggerCondition[];
}

Properties

type
PopupTriggerType
required
Type of trigger to use
value
number | string
required
Value configuration for the trigger:
  • time_on_page: seconds on page (number)
  • scroll: scroll percentage 0-100 (number)
  • exit: seconds before exit (number)
  • click: element id (string)
  • event: custom event name (string)
condition
PopupTriggerCondition[]
List of additional conditions that must be met for the popup to trigger

Example Usage

import { TriggerConfig } from '@magicfeedback/popup-sdk';

// Show survey after 5 seconds
const timeTrigger: TriggerConfig = {
  type: 'time',
  value: 5000, // milliseconds
  surveyId: 'survey-123'
};

Trigger Type Comparison

Trigger TypeValue TypeUse CaseExample Value
time / time_on_pagenumberDelay after page load5000 (5 seconds)
scrollnumberScroll depth percentage75 (75% scrolled)
exitnumberExit intent detection2 (2 seconds)
clickstringElement interaction'submit-button'
eventstringCustom app event'checkout_complete'

Build docs developers (and LLMs) love