Events

Based on the respondent's interaction with our surveys you can trigger actions in your app or website, or even build custom integrations. You can set up listeners to hook into user interactions with our surveys.

Event listeners can only be used on some of the paid plans. Check our pricing page for more details. We refer to this feature as 'Advanced Targeting' or 'JavaScript Targeting'.

By calling the addEventListener method multiple times, you can set up more than one listener for a given event.

If you don't need the listener anymore, you can use removeEventListener method to remove the previously registered listener. It is possible to remove either all the listeners that are hooked into a given event or a single listener based on the listenerId returned from the addEventListener method.

Please note: All events are emitted asynchronously - we cannot guarantee that the event has already been reflected in Survicate at the time of the emission. For instance, an answer for a certain question might not be present in Survicate yet.


Event-based targeting

In order to show surveys based on triggered events you can use invokeEvent method.

If only event name was provided in panel, pass it's name as an argument to invokeEvent method.

If also event properties were provided in panel, pass them as an object to invokeEvent method as second argument.

Important to note: Event name, properties keys and values are case sensitive. If there is any discrepancy between what's declared in the ‘Triggers’ tab of the Target section in the Survicate panel and the code, the survey will not appear.

Survey displayed

Every display of a survey is followed by the survey_displayed event emission.


Question answered

As soon as the visitor answers a question, Survicate emits the question_answered event.

Example 1: Set a cookie after response to specific question

Example 2: Open Intercom messenger after response to specific question

Answer object properties

PropertyTypeDescription
answer_typestringAnswer type.
answer_idintegerAnswer ID. Applicable only for type = ['single', 'smiley_scale', 'dropdown_list'].
answer_idsinteger[]Array of answer IDs. Applicable only for type = ['multiple'].
answer_valuestringContext value of the answer. Applicable only for type = ['text', 'nps', 'date', 'rating'].

Please note: At the moment we support passing the answer_id, answer_ids and answer_value properties only for the cases enlisted in the table above. Therefore, expect that there might be answer objects that consist only of the answer_type property.


Survey completed

Once a survey has been completed, Survicate emits the survey_completed event. Survey is considered to be completed, when a visitor has answered every single question that was displayed to them in the configured flow.


Survey closed

If at any stage of the survey, your visitor clicks the close button, Survicate will emit the survey_closed event.

Script loaded

Important to note: This reffers only to manual intallation of Survicate script.

As soon as the Survicate script has been fully loaded and ready, you will be informed through the SurvicateReady window event. This event is especially useful for the Single Page Applications/Progressive Web Applications.

Example: Reset visitor after script has been loaded

Please note: Due to its nature, unlike the other events, the SurvicateReady event is attached to the window object and not the _sva object.