How can I get EmbeddedData in | XM Community
Skip to main content

In a QX survey we’ve set EmbeddedData to hardcoded value via the Survey Flow UI interface. In the HTML header we’ve included some JavaScript code and in questions we’ve included JavaScript code for trying to getting EmbeddedData into JS code business logic. We debug the JS code in the QX survey preview mode.

The challenge we are facing is that, no matter what QX API/SDK suggestions we found in the docs/community so far we tried, we cannot access EmbeddedData from within JS code:

const seenQTagsED = Qualtrics.SurveyEngine.getEmbeddedData('seenQuestions');

const seenQTagsED = Qualtrics.SurveyEngine.getJSEmbeddedData('seenQuestions');

const seenQTagsED = "${e://Field/seenQuestions}";


The JavaScript Question API https://api.qualtrics.com/82bd4d5c331f1-qualtrics-java-script-question-api-class was not helpful at all to get our integration further so far (Contains deprecated API methods, lacks signature docs, ...).

Hi @thinwybk,

Can you please try to capture this on ready event?

var seenQTagsED = “${e://Field/seenQuestions}”;

Also, can you make sure that you test this using the proper preview link of the survey so that the JS gets executed??


@Sowrabh1993 Could it be that EmbeddedData cannot be loaded into JavaScript code in preview mode? Probably loading EmbeddedData is possible in “live” mode only...


@thinwybk,

That should not be the case. It works in preview as well. Can you share a snapshot of the code that you have written?


@Sowrabh1993 Does not help in “preview” mode as well. Do I need to “enable” JavaScript APIs via the Qualtrics UI somehow probably?
 

 


Same for ExternalDataReference... if I try to get ExternalDataReference into the JS code in “preview” mode it does not work. QX pastes an empty string into the variable instead of the actual value set in the contact list used to define the ExternalDataReference. (According to QX docs the JS code syntax to get ExternalDataReference and EmbeddedData should be exactly the same.)

 

ExternalDataReference is properly set in Survey Flow:
 

 

This is the actual, question specific JS code:


This is what results in “preview” mode (via browser console)… no matter into what QX API method I put the code into:

 

 

 

 


If I publish the survey (publish button) and try to get the data in “publish mode” it’s the exact same behavior.


If you are pulling anything from contact list, it won’t be pulled in preview mode as the preview is not attached to any contact list respondent.

You can alternatively assign a value to ExternalDataReference embedded data in the survey flow while previewing and then make sure to remove it once preview is done.

Try to hardcode the value to the embedded data in survey flow and then it should pick up the value.


Can you confirm that I cannot get EmbeddedData from header scope JavaScript? At least the builtin IDE seems to raise an issue here.
 


I’ll try out in question scope JavaScript again.


Finally found out that only a single one of the documented QX API variants works to get EmbeddedData. Works in “preview” mode when hardcoding a value (string).
 

 


Hi @thinwybk,

Can you please try to capture this on ready event?

var seenQTagsED = “${e://Field/seenQuestions}”;

Also, can you make sure that you test this using the proper preview link of the survey so that the JS gets executed??

W.r.t. typing this variant is pretty wired cause it might raise “Failed to evaluate page script” issues. See browser debug session above. Personally I’ll not use this one.


The following is simply an example of reading and setting embedded data variables within javascript. Please note that you must prefix the embedded data variable within the survey flow, using a `__js_` prefix in order to read it using Javascript. As of Sept. 2025, the documentation at https://api.qualtrics.com/82bd4d5c331f1-qualtrics-java-script-question-api-class explains the `getJSEmbeddedData` and `setJSEmbeddedData` functions. To test this, create an embedded data variable in the survey flow named `__js_TestEd` and set the value to `this is just embedded data set from the survey flow (123)`. Then within the survey add a `Text/Graphic` question and  edit the Javascript for the question to:

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/
    var myv = Qualtrics.SurveyEngine.getJSEmbeddedData('TestEd');
    alert(myv);
    
    Qualtrics.SurveyEngine.setJSEmbeddedData('TestEd', 'now we changed the embedded variable value (567)');
    myv = Qualtrics.SurveyEngine.getJSEmbeddedData('TestEd');
    alert(myv);
});

When the survey question is loaded, a pop up alert will display with the value of the `__js_TestEd` embedded data variable set in the survey flow. Next a second alert will pop up with the new value of the 'TestEd' embedded variable. Keep in mind, that once you are in Javascript, you do not include the `__js_` prefix when getting or setting the embedded variable. Do not ask me why Qualtrics thought it would be useful to force the convoluted `__js_` prefix on embedded variables set in the survey flow in order to read them within Javascript (I have no idea and believe it was a horrible design decision from an end-user perspective).