JavaScript and MaxDiff Most Preferred selections | XM Community
Solved

JavaScript and MaxDiff Most Preferred selections

  • 6 October 2023
  • 8 replies
  • 113 views

Badge +1

I’m hoping for help with accessing the data from a MaxDiff question via JavaScript.

For context, I am trying to create a MaxDiff survey with conditional follow-up questions. So if someone selects feature X during any of the MaxDiff questions as most preferred, then at the end of the survey they see the "feature X follow-up question." If they did NOT select feature X as most preferred, then they do NOT see that follow-up.

I see that MaxDiff questions do not work with survey logic. So I am trying to get it to work with JavaScript.

From an export of the data, I found the variable names associated with the MaxDiff selections:

QID1_1

QID1_2

QID1_3

Which then correspond with the order of concepts in the following variables:

1.1_MAXDIFF

1.2_MAXDIFF

1.3_MAXDIFF

But I can’t figure out how to access the value in JavaScript.

When I return a console.log of the following MaxDiff variables, it returns nothing: 

temp_MaxD_Question = '${q://QID1_1}';
console.log("temp_MaxD_Question = " + temp_MaxD_Question);

 

With a multiple choice question, I know to append “/ChoiceGroup/SelectedChoices” which when returning in as console.log, returns the value of what was selected:

temp_MC_Question = '${q://QID7/ChoiceGroup/SelectedChoices}';
console.log("temp_MC_Question = " + temp_MC_Question);

 

Does someone you show me how to access the value of the variables like QID1_1 and 1.1_MAXDIFF? 

 

I found the post below, but it only suggestions JavaScript as a solution. It does not describe how to do it. 

 

Thanks a ton!

icon

Best answer by TomG 31 October 2023, 13:37

View original

8 replies

Badge +2

I don’t know js, but I have this need too! I want to pipe forward all items selected as “most” from a maxdiff into a  Likert. 

Badge +1

@Phigam01 I never discovered a way to do this. 😩

Userlevel 7
Badge +27

@Phigam01,

I believe you want to pipe the following into your follow-up Likert:

${q://1_QID1/ChoiceGroup/SelectedChoicesForAnswer/1}

${q://2_QID1/ChoiceGroup/SelectedChoicesForAnswer/1}

${q://3_QID1/ChoiceGroup/SelectedChoicesForAnswer/1}

...etc...

Badge +1

Thanks for the response, @TomG . I tried what you suggested. Piping the data with your syntax returned nothing. And when I tried to do a console log with JavaScript, it also returned nothing. 

 

I then tried similar syntax that matches the variable name in the export file, “${q://QID1_1/”: 

${q://QID1_1/ChoiceGroup/SelectedChoicesForAnswer/1

It also did not match.

Userlevel 7
Badge +27

Thanks for the response, @TomG . I tried what you suggested. Piping the data with your syntax returned nothing. And when I tried to do a console log with JavaScript, it also returned nothing. 

 

I then tried similar syntax that matches the variable name in the export file, “${q://QID1_1/”: 

${q://QID1_1/ChoiceGroup/SelectedChoicesForAnswer/1

It also did not match.

What I gave you is what you would pipe from a Maxdiff question. My guess is that it isn’t working because what you are trying to pipe is itself piped.

I think your best hope is to run JS from the header to capture and save the most choices to embedded data fields.

Badge +1

What I gave you is what you would pipe from a Maxdiff question. My guess is that it isn’t working because what you are trying to pipe is itself piped.

I think your best hope is to run JS from the header to capture and save the most choices to embedded data fields.

 

Interesting and creative thinking, @TomG ! Hopefully I can figure out how but sounds it should work! Thanks!

Badge +1

@brannan_m - were you able to find a solution for this? I am also very interested in being able to do this.

Badge +1

@brannan_m - were you able to find a solution for this? I am also very interested in being able to do this.

Unfortunately, I did not. Sorry!

Leave a Reply