Skip to content

Event Handling

You can hook onto Appzi survey events by using the onEvent callback.

window.appziSettings = {
onEvent: (evt) => {
console.log('Event:', evt.type, 'Survey:', evt.surveyId);
},
};
window.appziSettings = {
onEvent: (evt) => {
if (evt.type === 'open-survey') {
launchFireworks();
}
},
};

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();
}
},
};

The event object passed to onEvent has the following structure:

{
type: 'open-survey',
surveyId: string // The survey configuration ID
}