Is there a way to delay the survey from showing up for first time visitors to my site?

Andreas Knecht Community Champion Jun 08, 2016

I don't want users to be polled immediately when they first visit my site. Is there a way to delay polling for first time visitors?

1 answer

1 accepted

1 vote
Andreas Knecht Community Champion Jun 08, 2016

You have full control over how you embed the survey in your site.  You could for example achieve this by setting a timestamp in localstorage like this:

<script   src="https://code.jquery.com/jquery-2.2.4.min.js"   integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="   crossorigin="anonymous"></script>
<script>
(function() {
  var firstVisitDate = window.localStorage.getItem("firstVisit");
  if(firstVisitDate === null) {
    window.localStorage.setItem("firstVisit", Date.now());
  } else {
    if(Date.now() > (parseInt(firstVisitDate) + (24*60*60*1000))) {
      window.CODEBARREL_NPS = {
          getUserId: function () {
              return undefined;
          }
      };
      $.when(
        $.getScript("https://nps-for-jira.codebarrel.io/676c3c95851177199ebf9f5f3f1747/js/i18n.pack.js"),
        $.getScript("https://nps-for-jira.codebarrel.io/676c3c95851177199ebf9f5f3f1747/js/npssurvey.pack.js"),
        $.Deferred(function(deferred){$(deferred.resolve);}))
      .done(function() { 
        $.getScript("https://nps-for-jira.codebarrel.io/rest/remote/survey-init.js?surveyId=d8c0d83f-8da3-4574-8007-cabd0c8b6c17&clientKey=jira:2c5273f3-2840-4087-bc1f-485df7dd34");
      });
   }
  }
})();
</script>

 

This code inserts a timestamp in local storage on first visit to your site, and then compares this timestamp on subsequent visits to check if it is older than 24 hours.  The NPS survey javascript will only be requested if this condition is met.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

173 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you