Skip to main content

Surveys

The survey methods allow you to display surveys, navigate between pages, snooze surveys, and manage completion state. All methods are available on window.USETIFUL.surveys after the usetiful:fullApiReady event has fired.

Survey IDs are string identifiers assigned in the Guides and Surveys dashboard when creating or editing a survey. Multi-page surveys use 0-indexed page numbers.


start(surveyId, pageIndex?)

Displays a survey by its ID. By default, the survey opens on the first page (index 0). Use the pageIndex parameter to open the survey on a specific page.

ParameterTypeRequiredDefault
surveyIdstringYes
pageIndexnumberNo0

close(id?)

Closes a survey. When an id is provided, that specific survey is closed. When called without arguments, the currently active survey is closed.

ParameterTypeRequired
idstringNo

goToNextPage()

Advances to the next page of the currently active survey. If the survey is on its last page, calling this method has no effect.


goToPage(pageIndex)

Jumps to a specific page of the currently active survey. Pages are 0-indexed.

ParameterTypeRequired
pageIndexnumberYes

showLaterSurvey(id?, duration?, timeUnit?)

Snoozes a survey so that it reappears after a specified delay. When called without arguments, the currently active survey is snoozed with the default delay configured in the dashboard.

Provide duration and timeUnit to set a custom snooze period. Supported time units include 'minutes', 'hours', and 'days'.

ParameterTypeRequired
idstringNo
durationnumberNo
timeUnitstringNo

isSurveyCompleted(surveyId)

Returns whether a survey has been completed by the current user.

Returns: boolean

ParameterTypeRequired
surveyIdstringYes

completeSurvey(surveyId)

Manually marks a survey as completed for the current user. Use this method when you need to mark a survey as done without the user having submitted it through the UI, for example after processing the response in your own application logic.

ParameterTypeRequired
surveyIdstringYes

uncompleteSurvey(surveyId)

Removes the completed status from a survey for the current user, allowing it to be displayed again. Use this method when a survey needs to be re-shown, for example after a product update that warrants collecting new feedback.

ParameterTypeRequired
surveyIdstringYes