Event Handling
You can hook onto Appzi survey events by using the onEvent callback.
Basic Event Handling
Section titled “Basic Event Handling”window.appziSettings = { onEvent: (evt) => { console.log('Event:', evt.type, 'Survey:', evt.surveyId); },};Trigger a Function When Survey Opens
Section titled “Trigger a Function When Survey Opens”window.appziSettings = { onEvent: (evt) => { if (evt.type === 'open-survey') { launchFireworks(); } },};Filter Events by Survey ID
Section titled “Filter Events by Survey ID”If you have multiple surveys on a page, you can filter based on the surveyId property:
window.appziSettings = {onEvent: (evt) => { if (evt.type === 'open-survey' && evt.surveyId === 'CONFIG_ID') { handleSpecificSurveyOpen(); }},};Event Object Structure
Section titled “Event Object Structure”The event object passed to onEvent has the following structure:
{ type: 'open-survey', surveyId: string // The survey configuration ID}