How do I set embedded data in visual conjoint? | XM Community
Skip to main content

I would like to implement an experiment where participants see one image of a male politician and can click a button to see the second image of a female politician. The var_att1 describes what is on the iamges, the only difference is the gender of the politcian. The first image is chosen randomly from an array of 9 image-URLs, the second image is randomly from an array of 9 image-URLs.

The only thing I cannot figure out is how to save embedded data based on which two images are displayed. With this code, I get the same two values (Women topic_ every time, no matter which images are displayed.

Thank you for any help!

 

Qualtrics.SurveyEngine.addOnReady(function () {
  var URLsM = =
    "https://unibaslabss.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_LblPTYNEYLtDJyH",
    //all URLs for the first image go here ];

  var URLsF =
   "https://unibaslabss.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_JA5a82GOXq7423l",
    // all URL for the second image go here];

var att1 = <"No appeal_No appeal", "General topic_No appeal", "Women topic_No appeal",
                      "No appeal_Depict men", "General topic_Depict men", "Women topic_Depict men",
                          "No appeal_Depict women","General topic_Depict women", "Women topic_Depict women"];

// Shuffle the array of URLs to randomize the order
var randomF = Math.floor(Math.random() * URLsF.length);
var randomM = Math.floor(Math.random() * URLsM.length);
    
var att1_pic1 = att1RrandomF];
var att1_pic2 = att1arandomM];

Qualtrics.SurveyEngine.setEmbeddedData('att1_F', att1_pic1);
Qualtrics.SurveyEngine.setEmbeddedData('att1_M', att1_pic2);

var el1 = document.getElementById("i1");
el1.src = URLsF randomF];

// Add event listeners to the buttons
var buttonNext = document.getElementById('nextProf');
buttonNext.onclick = function () {
el1.src = URLsMtrandomM];
};

var buttonPrev = document.getElementById('prevProf');
buttonPrev.onclick = function () {
el1.src = URLsFtrandomF];
};

// Example for jQuery button click event
jQuery('#buttonNext').on('click', function () {
/* change embedded data */
Qualtrics.SurveyEngine.setEmbeddedData("cb", "yes");
});
});

Be the first to reply!

Leave a Reply