Surveys

Description

This JS API provides you access to surveys. Access methods on this object:

productFruits.api.surveys

Methods

startSurvey(surveyId)

A string ID of the survey. You can get the survey ID from the URL in the Product Fruits administration - the last GUID parameter.

listen(callbackType, callback)

Listens to an event that occurs on surveys. See the next section to get event names. The listen method returns a function. If you want to clear the attached event handler, call that function. For example:

const disposeFn = productFruits.api.tours.listen('survey-closed', yourCallback);

// ... later

disposeFn();

Events

survey-closed

Arguments:
surveyId - GUID of the survey
reason - either last_screen or close_button
answers - an array of answers, one answer object looks like:
    additText - for choice types of answer, if "Other" is selected, this will get the free text
    answer - the answer value, string|number|Array<string|number>
    questionId - question ID

Triggered when a user closes a survey. It can be triggered either by clicking on the close button or when the last question was answered.

Answer values are different based on the question type. E.g. multiple choices questions will get an array of strings (answer IDs), but the single-choice type will get only the string ID.