I'm experiencing an issue with storing Embedded Data in my Qualtrics survey that uses Google Maps API. While the console shows the data is being saved successfully, the Embedded Data fields are empty when exporting the survey results.
Here's the detailed situation:
- Survey Setup:
- Created a map selection question using Google Maps API
- Embedded Data fields (SA1_Code, SA2_Code, SA2_Name, Search_Address) are set up in Survey Flow before the Question Block
- The code collects and attempts to store area codes and names when users select locations
- Current Behaviour:
- Console shows "Data saved successfully" with correct values
- Verification step in the code confirms data is saved
- However, when exporting survey data, all Embedded Data columns are empty
- Relevant Code:
function handleConfirmClick() { if (currentFeature) { const sa1Code = currentFeature.getProperty('SA1_CODE21'); const sa2Name = currentFeature.getProperty('SA2_NAME21'); const sa2Code = currentFeature.getProperty('SA2_CODE21'); const searchAddress = searchInput.value;
try { // Store data Qualtrics.SurveyEngine.setJSEmbeddedData('SA1_Code', sa1Code); Qualtrics.SurveyEngine.setJSEmbeddedData('SA2_Name', sa2Name); Qualtrics.SurveyEngine.setJSEmbeddedData('SA2_Code', sa2Code); Qualtrics.SurveyEngine.setJSEmbeddedData('Search_Address', searchAddress);
// Prepare response object const response = { SA1_Code: sa1Code, SA2_Name: sa2Name, SA2_Code: sa2Code, Search_Address: searchAddress };
// Create or update form field let formField = document.querySelector('inputname="QR~' + that.questionId + '"]'); if (!formField) { formField = document.createElement('input'); formField.type = 'hidden'; formField.name = 'QR~' + that.questionId; that.getQuestionContainer().appendChild(formField); } formField.value = JSON.stringify(response);
// Show confirmation and verify data resultDiv.innerHTML = 'Selection confirmed! Saving data...'; confirmButton.style.display = 'none';
Qualtrics.SurveyEngine.addOnUnload(function() { // Only log verification if we have data const sa1Code = Qualtrics.SurveyEngine.getJSEmbeddedData('SA1_Code'); if (sa1Code) { const finalData = { SA1_Code: sa1Code, SA2_Name: Qualtrics.SurveyEngine.getJSEmbeddedData('SA2_Name'), SA2_Code: Qualtrics.SurveyEngine.getJSEmbeddedData('SA2_Code'), Search_Address: Qualtrics.SurveyEngine.getJSEmbeddedData('Search_Address') }; console.log('Final data verification:', finalData); } });
- What I've Already Done:
- Confirmed Embedded Data fields are properly set up in Survey Flow before the Question Block
- Added verification steps in the code
- Implemented error handling
- Added console logging for debugging
Questions:
- Why isn't the data being stored in the Embedded Data fields despite successful console output?
- Are there alternative methods to ensure the data is properly stored?
- Do I need to modify any Survey Flow settings?