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

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!

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


Leave a Reply