Link Search Menu Expand Document


Table of contents

  1. Retarget
  2. Get visitor ID
  3. Set visitor traits
  4. Reset visitor
  5. Show survey


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 retarget method.

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 getVisitorId method.

var visitorId = _sva.getVisitorId();

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 setVisitorTraits method.

  "email": "Respondent's email",
  "first_name": "Respondent's name",
  "last_name": "Respondent's last name", 
  "my_custom_attribute": "Custom attribute value"

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.

Reset visitor

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.

_sva.destroyVisitor(function() {
  console.log(Data deleted);

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.


Show survey

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).

var options = {
  forceDisplay: true,
  displayMethod: 'delayed',
  displayOptions: {
    delay: 5

_sva.showSurvey('abc1234', options);

Optionally, to change the default behavior of the survey, you can provide the options object as the second parameter.


Property Type Description
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’.


Property Type Description
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’.

← Configuration Events →

👋 If you bump into any problems or need more support, just start a conversation using Intercom in the bottom-right corner and you will be immediately routed to our Customer Support Engineers.