Learn how to handle events with the Saypien JavaScript Library
Note: The Saypien JavaScript Library provides several event callbacks that you can use to execute custom functions at different stages of the survey lifecycle.
The Saypien JavaScript Library supports the following event callbacks:
onOpen
: Triggered when the overlay is opened.onClose
: Triggered when the close button is clicked.onStart
: Triggered when the survey is started.onComplete
: Triggered when the survey is completed.Here is an example of how to use these event callbacks:
The onComplete
callback is executed when the survey is completed by the user. This is useful for performing actions such as showing a thank you message or redirecting the user to another page.
The onClose
callback is triggered when the user clicks the close button on the survey overlay. You can use this to log the event or to perform any cleanup actions.
The onOpen
callback is executed when the survey overlay is opened. This can be useful for tracking the event or initializing certain states.
The onStart
callback is triggered when the survey is started by the user. This can be useful for logging the start event or for analytics purposes.
You can combine multiple event callbacks to handle different events within the survey lifecycle.
If your event callbacks are not working as expected, here are some common issues to check:
The callback function is not being executed
Ensure that the function is correctly defined and that it is being passed in
the configuration object of the initialize
method.
An error is displayed in the console
Check the syntax of your JavaScript code and make sure all required parameters are provided correctly.
Learn how to handle events with the Saypien JavaScript Library
Note: The Saypien JavaScript Library provides several event callbacks that you can use to execute custom functions at different stages of the survey lifecycle.
The Saypien JavaScript Library supports the following event callbacks:
onOpen
: Triggered when the overlay is opened.onClose
: Triggered when the close button is clicked.onStart
: Triggered when the survey is started.onComplete
: Triggered when the survey is completed.Here is an example of how to use these event callbacks:
The onComplete
callback is executed when the survey is completed by the user. This is useful for performing actions such as showing a thank you message or redirecting the user to another page.
The onClose
callback is triggered when the user clicks the close button on the survey overlay. You can use this to log the event or to perform any cleanup actions.
The onOpen
callback is executed when the survey overlay is opened. This can be useful for tracking the event or initializing certain states.
The onStart
callback is triggered when the survey is started by the user. This can be useful for logging the start event or for analytics purposes.
You can combine multiple event callbacks to handle different events within the survey lifecycle.
If your event callbacks are not working as expected, here are some common issues to check:
The callback function is not being executed
Ensure that the function is correctly defined and that it is being passed in
the configuration object of the initialize
method.
An error is displayed in the console
Check the syntax of your JavaScript code and make sure all required parameters are provided correctly.