How to record when the "previous" button is used? | XM Community
Question

How to record when the "previous" button is used?


Dear all,
I am wondering if there is a simple way to collect data on the use of the "Previous" button. I have the "Timing" question in mind, which collects data on the "Next/Page Submit" button.
Ideally, I would like to record the number of times a user clicks on the "Previous" button of a particular page. My initial idea was to append the question ID to an embedded variable (which would work as a list) in a click event in the custom javascript of a question. If someone has a snippet of code that does just that I would be very grateful.
Thanks, Thomas


3 replies

Using a comment from TomG on this post, I have come up with the following code, where I initially create an empty embedded data "backbutton" in the survey flow:
  var qid = this.questionId;
  var back = Qualtrics.SurveyEngine.getEmbeddedData("backbutton");
  jQuery("#PreviousButton").click(function() { 
      if (back == null) {
         back = qid + "-";
      } else {
         back = back + qid + "-";
      };
However, I have looked for a way to append the question custom label/tag (i.e. "DataExportTag") instead of the question ID in vain. Does someone know of a way to do so?

Userlevel 7
Badge +27

I believe the only way to get the question label is to turn on Question Numbers under Survey Options. Then it is a label with the class ExportTag. You'll have to have your JS hide it if you don't want the respondent to see it.

Userlevel 5
Badge +4

You can fetch the export tag using the below,
var currQn =  jQuery('.ExportTag').html().slice(0,-1);
store the currQn in embedded data variable.
This is to work in live mode, you will have to enable the question numbers in live and you have to hide the question numbers using the CSS.

Leave a Reply