Targeting a website survey once per user

How to trigger a website survey only once per user: setting up event listeners to pass survey_displayed event as a user attribute.

Agnieszka avatar
Written by Agnieszka
Updated over a week ago

Targeting a Website or in-product survey once per user with the use of our JavaScript API can be useful when you want to make sure no one answers your survey more than once, in case:

  • a website visitor clears their browser cache and is treated as a new respondent;

  • a respondent enters your website from a different browser or from another device.

In this article, you'll learn how to show a website survey only once per user by passing the survey_displayed an event as an attribute to your website.

💡This article can also be used for events such as question_answered or survey_completed - depending on what you want to achieve. For more information, please visit our developer documentation.

📌 This feature is available on some of the plans (included in the JavaScript API feature). If you are interested in testing the possibility of showing your Website or in-product survey only once per user, drop us a line at or talk to us in chat.

Create a Website or in-product survey.

In the Target > Frequency tab of your survey, you can choose to Never show the survey again after someone has closed it or answered it:

However, if the respondent opens the website where the survey is shown from another browser, or another device, or clears the browser cache, this setting is not enough to prevent them from seeing and answering the survey again.

To make sure they won't be able to respond again, please follow the below steps.

Step 1. Pass the survey_displayed attribute to Survicate

1. To pass the survey_displayed attribute to Survicate from your database, it's necessary to first install the Survicate tracking code on your website.

Please follow this guide to learn how to set it up.

2. Identify your respondent and add an attribute such as survey_displayed to your Survicate tracking code:

<script type="text/javascript"> 
(function(opts) {
opts.traits = { "survey_displayed": user.displayed // user.surveydisplayed should be changed for relevant value - preferably boolean
})(window._sva = window._sva || {});

This attribute needs to be stored in your database as a user attribute to make sure it's consistent and does not depend on the platform or browser cache. It will assign the survey_displayed attribute with value true to respondents who answered your survey.

Step 2. Target the survey

1. Go to the Target tab in your Survicate panel and click on the Audience on the left:

2. Choose New Audience, add a name, and create a new audience for your survey:

3. Click on Add Filter and choose Attributes:

💡 Make sure to add attributes to your tracking code as explained above, before selecting this option.

4. In our example, the name should be survey_displayed and value should be false - this way, you make sure to target users who have not answered the survey.

5. Click on Create Audience to save changes.

6. Enable the chosen Audience to display the survey correctly:

Step 3. Set up the function to update the user profile

You need to set up EventListener to check when the user has answered a survey. When they do, you should change the survey_displayed flag in your database to true.

To achieve this, please use the code from below adjusted to your survey:

_sva.addEventListener('survey_displayed', function(surveyId) { 
if (surveyId == "65f93ff602c63b57") { // change survey id to id of your survey
// here you should update the user attribute in your database to "true"


I don't see the survey even though I haven't answered it yet

Please check if your Audience doesn't have any other user characteristics set up. If, besides the survey_displayed attribute, your Audience requires the respondent to, for example, use a certain device or visit the website at least 3 times. You need to match those criteria as well to see the survey:

📞 If you have any questions about targeting a Website or in-product survey once per user, please reach out to us at or strike up a chat conversation.

Did this answer your question?