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_seen 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. 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 sales@survicate.com or talk to us in chat.

Table of contents:

  1. Pass the survey_seen attribute to Survicate

  2. Target your survey

  3. Set up the function to update the user profile

  4. Troubleshooting

  5. Best practices

In the Target > Frequency tab of your Website or in-product 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, 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_seen attribute to Survicate

1. To be able to pass the survey_seen 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_seen to your Survicate tracking code:

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

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_seen 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_seen and value should be false - this way you make sure to target users that 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_seen flag in your database to true.

To achieve this, please use 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"
}
});

Troubleshooting

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_seen 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:

Best practices

Enable Product Integrations

Once your Website or in-product survey starts collecting responses, feel free to enable the Mixpanel, Productboard, or Amplitude integration in the Connect tab of your survey to track feedback from your website visitors.

Run multilingual surveys

Try our automatic translations feature to show your respondent's surveys adjusted to their browser language and increase the response rate.

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

Did this answer your question?