How can I make a counter in JavaScript into Embedded data? | XM Community
Skip to main content
Solved

How can I make a counter in JavaScript into Embedded data?

  • May 7, 2021
  • 2 replies
  • 174 views

I have a variable counter that records the number of times a button is clicked in Javascript, but I'm having trouble getting that as Embedded Data. The embedded data function seems to be working, but instead of counting the number of clicks, it just records 0 as the embedded data.
I put the following in my JavaScript code. "stops_click" is the embedded data that I've set in Survey Flow. wait_count is the counter variable. The counter seems to be working, since I was able to print the number of counts.
Qualtrics.SurveyEngine.setEmbeddedData("stops_click", wait_count); 

Best answer by ahmedA

You'll need to trigger it on the click or while exiting, otherwise, it will just record it the moment the page loads, at that time it's zero, and then go to sleep happy that it's done it's job.

2 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Answer
  • May 7, 2021

You'll need to trigger it on the click or while exiting, otherwise, it will just record it the moment the page loads, at that time it's zero, and then go to sleep happy that it's done it's job.


  • Author
  • May 7, 2021

Thanks, I got it to work once I counted the clicks!