The SatisMeter web widget supports the following JavaScript events:
display: SatisMeter displays the survey to the user.progress: The user answers a question.complete: The user completes the survey. Completion happens when the user goes through all the questions, or closes the survey after answering at least one question.dismiss: The user closes the survey without answering any questions.
Use these events on the client side for use cases such as opening a chat window when a user leaves certain feedback.
Example
satismeter({
writeKey: "XXXXXXXXXX",
userId: "1234",
traits: {
createdAt: "2016-08-05T09:46:37.244Z",
...
},
events: {
display: function(event) {
console.log('survey displayed');
},
progress: function(event) {
console.log('question answered');
},
complete: function(event) {
console.log('survey submitted');
},
dismiss: function(event) {
console.log('survey dismissed');
}
}
});
Each callback receives an event object with more information about the survey and the user's answers.
For display and dismiss, the event object contains one field:
campaign: A string containing the survey ID. To find the ID of any of your surveys, go to Settings > Integrations > API Keys and look under Survey keys.
For progress and complete, the event object contains two fields:
campaign: The same field as described above.answers: A list of all the answers the user has given. Each item in the list is an object with three fields:id: A string containing the question ID. You can find it in the same place as the survey ID: Settings > Integrations > API Keys, under Survey keys.label: A string containing the question text shown to the user.value: The value of the answer.