Realt time display for button counter | XM Community
Skip to main content
Question

Realt time display for button counter

  • August 8, 2022
  • 1 reply
  • 156 views

Hi - I have set up a button and counter (usingsurvey flow embedded data, question button html and question javascript, but am wondering if I can set up a real time visual display of the number of times the button in pressed - so that the presser can see the count go up in real time?
Thank you!

1 reply

Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • August 11, 2022

Hi there, I've used the following before. First, create an Embedded Data Element at the top of the Survey Flow and create an Embedded Data field called "clicks".
Then, in the question's HTML, put the below:




Clicks: 0
Finally, in the question's JavaScript, put the below in the Onload section:
var count=0

document.getElementById("button1").onclick=function(){
    count=count+1;
    document.getElementById("counter").innerHTML=count;
    Qualtrics.SurveyEngine.setEmbeddedData('clicks', count);
}