In this guide, we will walk you through the steps of showing a website survey only once per user, passing survey_seen event as an attribute to your website, so your users won't see the survey again even if they open the survey from another browser, or clear their cache.

This guide can be used also on events like question_answered or survey_completed - depending on what you want to achieve. For more information please visit our developer documentation.

Passing attributes to Survicate

Identify your respondent and add an attribute like "survey_seen":

<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 || {});

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.

Targeting the survey

1. Go to Target section in your panel and click on the Audience on the right sidebar.

2. Choose New Audience 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 this case, 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.

Setting 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 survey_seen flag to true.

_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"
Did this answer your question?