Help Updating Open-Ended Question Text Based on NPS Score | XM Community
Skip to main content

Hi everyone,

I'm trying to dynamically change the text of an open-ended question on the same page as an NPS question in Qualtrics, based on the NPS score the respondent selects.

The idea is to keep just one open-ended question, but with different wording depending on the score:

  • 9–10 (Promoter): "Você poderia comentar o que mais gostou?"

  • 7–8 (Neutral): "Comente por favor, o que faltou para sua experiência ser melhor:"

  • 0–6 (Detractor): "Comente por favor, o que não saiu como esperado:"

I've tried several JavaScript approaches, but nothing seems to update the question text correctly once a choice is selected.

If anyone has working code (especially for the standard NPS question type), or knows a reliable method that works within Qualtrics' constraints, I would be really grateful.

Thanks in advance for your help!

With ChatGPT’s assistance

 

Hi ​@Erikahuer ,

try pasting the code below in the text entry question.

Qualtrics.SurveyEngine.addOnload(function () {
var npsQuestionId = 'QID1'; // 🔁 Replace with your actual NPS question ID
var textEntryContainer = this.getQuestionContainer();
var textEntryDescription = textEntryContainer.querySelector('.QuestionText');

// Function to change the description
function updateDescription(score) {
let message = '';
if (score >= 0 && score <= 6) {
message = 'Comente por favor, o que não saiu como esperado:';
} else if (score >= 7 && score <= 8) {
message = 'Comente por favor, o que faltou para sua experiência ser melhor:';
} else if (score >= 9 && score <= 10) {
message = 'Você poderia comentar o que mais gostou?';
}
if (textEntryDescription) {
textEntryDescription.innerHTML = message;
}
}

// Wait a little to make sure all elements are loaded
setTimeout(function () {
var npsContainer = document.getElementById(npsQuestionId);
if (!npsContainer) return;

var radios = npsContainer.querySelectorAll('input[type="radio"]');

radios.forEach(function (radio) {
radio.addEventListener('click', function () {
var val = parseInt(radio.value);
if (!isNaN(val)) {
updateDescription(val);
}
});
});
}, 250); // slight delay to ensure rendering
});

Illustration:

survey builder, code added to text entry question.
Description for 9/10
Description for 7/8
Description for 0 to 6

 


You can also create 3 different questions one for promoter, passive and detractor and show question based on the answer to NPS question with “in-page” display logic. for data analysis you can move data to one embedded field as at a time only one field have data.