PopupDefinition Interface
The complete TypeScript interface for popup definitions:Required Fields
id
Type:string
Unique identifier for the popup definition. Used for tracking, deduplication, and manual triggering.
When multiple popups share the same
surveyId, use the id field to distinguish between them. Use showByPopupId() to show a specific popup by its ID.title
Type:string
The title of the popup.
Note: The current browser renderer focuses on embedded MagicFeedback forms and does not render the
title field as standalone UI. This field is part of the contract for future renderers.message
Type:string (HTML)
The message content of the popup. Supports HTML.
Like
title, the message field is not currently rendered as standalone UI by the default browser renderer. It’s part of the definition contract for custom renderers.surveyId
Type:string
The ID of the MagicFeedback survey to display.
- Load the survey form from MagicFeedback
- Track survey completion
- Apply trigger conditions based on survey answered state
productId
Type:string
The product ID associated with this popup.
triggers
Type:PopupTrigger
Defines when and how the popup should be triggered.
Optional Fields
actions
Type:PopupActions
Defines the action buttons and their behavior.
- accept
- start
- complete
- decline
- back
Opens the survey when clicked.Fields:
label(string): Button textsurveyId(string): Survey to open
style
Type:PopupStyle
Customizes the appearance of the popup.
The current browser renderer does not fully implement all style options. These fields are part of the contract for future renderers and custom implementations.
segments
Type:PopupSegments
Defines targeting rules for when the popup should be shown.
segments.path is currently the only segment field evaluated by the SDK. Other fields like lang are accepted but not yet implemented.- Full URLs:
https://example.com/pricing - Path fragments:
/pricing - Hash routes:
/#/home - If
pathis empty or not provided, popup can trigger on any route
Complete Examples
Trigger Conditions Reference
Conditions are evaluated before showing a popup:answered
When set tofalse, the popup will not show if the user has already completed the survey.
- Automatic tracking when
survey_completedevent is emitted - Manual tracking via
popups.markSurveyAnswered(surveyId)
cooldownDays
Minimum number of days that must pass before showing the popup again to the same user.- SDK records the timestamp when a popup is shown
- Before showing again, SDK checks if
cooldownDayshave passed - Cooldown is tracked per popup
id, not per survey
Multiple Conditions
Multiple Conditions
You can provide multiple conditions, and all must pass for the popup to show:This configuration means:
- If user hasn’t answered: wait 7 days between shows
- If user has answered: wait 90 days between shows
Validation
The SDK validates popup definitions and logs warnings for invalid structures:Best Practices
Use Descriptive IDs
Use Descriptive IDs
Make popup IDs descriptive and follow a naming convention:
Set Reasonable Cooldowns
Set Reasonable Cooldowns
Balance feedback collection with user experience:
- High-priority feedback: 7-14 days
- General feedback: 30-60 days
- Low-priority surveys: 90+ days
Target Specific Routes
Target Specific Routes
Use
segments.path to show relevant popups on specific pages:Test in Client Mode First
Test in Client Mode First
Before deploying to production, test popup definitions locally:This allows you to:
- Validate definition structure
- Test trigger behavior
- Verify UI rendering
- Debug conditions and segments