Survicate fires the visitors targeting script whenever there is a need to find out, whether there is a survey that should be displayed to your visitor, for instance on such events as page load, survey's completion or path change in your Single Page Application. If you'd like to trigger an additional targeting script execution, you can use the
This feature can be especially useful for Single Page Applications / Progressive Web Applications or the callbacks of asynchronous methods.
Get visitor ID
As soon as your visitor answers any survey's question, we assign a unique ID to them. Feel free to keep your visitors using that ID using the
Note: The output of this method can be
null. As mentioned above, the value is assigned only to the visitors that have answered any question.
Set visitor traits
To set the visitor attributes asynchronously after the script is loaded, you can use the
Note: The visitor attributes will be updated locally straight away, but the change will be visible in Survicate as soon as they answer any question.
Survicate allows you to delete individual respondent’s browser data by using the destroyVisitor method. The method resets all respondent’s data stored in their localStorage, or sessionStorage. This information includes respondents attributes, sessions history, survey responses stored in the browser etc. The method will not delete already collected responses from our database, meaning they will be still accessible in the survey results tab. However, if this particular website visitors meets the targeting criteria set for the survey, the respondent will be able to see and answer the same survey again. Please note that if the method is called during the survey completion process, the survey will disappear, so the respondent will not be able to finish the survey.
Optionally, a callback function can trigger an action when using the destroyVisitor method. In this example, the callback function triggers retarget method, which will ‘check’ if there are surveys that should be shown to this, ‘new’ website visitor.
For the customers that need a custom targeting system, we provide the
showSurvey method, that makes it easy to show an arbitrary survey based on the given survey's id.
The method ignores all targeting options, except checking whether this visitor has already answered the survey.
The method returns
true if the survey was rendered and
false otherwise (e.g. another survey is already displayed or the visitor has answered the desired survey).
Optionally, to change the default behavior of the survey, you can provide the
options object as the second parameter.
|forceDisplay||boolean||If true, currently rendered survey will be closed in favor of the new survey. Survey will be shown regardless whether visitor has already answered this survey.|
|displayMethod||string||Use this option in order to overwrite the current displaying configuration. Possible values: ['immediately', 'delayed', 'exitIntent', 'onScroll'].|
|displayOptions||object||See below for available options. Applicable and required only for the displayMethod values 'delayed' and 'onScroll'.|
|delay||integer||Delay in seconds. Applicable and required only for displayMethod = 'delayed'.|
|scrolledPercentage||integer||Percentage of the page that was already scrolled. Applicable and required only for displayMethod = 'onScroll'.|