setVisitorTraits method is available for all users, including those on the free plan.
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 triggers the targeting script to determine if a survey should be displayed to a user. This happens during events like a page load, the completion of a survey, or a path change in the 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.
As soon as your user answers any survey's question, we assign a unique ID to them. Feel free to identify your users using that ID with the getVisitorId method
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.
Using the destroyVisitor method you can remove a user's browser data. This erases data like session history and survey responses from their localStorage and sessionStorage. However, responses already saved in our database remain untouched and can still be viewed in the survey results tab.
If a user matches a survey's targeting criteria, they might encounter the same survey again.
If you use this method while a survey is in progress, the survey will close and the user won't be able to complete it.
When using the destroyVisitor method, you can include a callback function to execute a specific action afterward. In this example, the callback function triggers the retarget method, which will ‘check’ if there are surveys that should be shown to this 'new' user.
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 of whether the user 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'.|
Disabling automatic targeting
The targeting script is automatically executed to determine if a user fits the specified criteria. We recognize that some users might prefer a different approach, such as using custom targeting with the _sva.showSurvey method. If you'd like to turn off this automatic feature, use the disableTargeting property.