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
Accepted answer
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
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,427 views 0 8
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