Search code examples
javascriptqualtrics

Qualtrics: How to get the values saved in Embedded Data in previous page?


I'm making a survey that displays a sequence of pictures with an associated phrase. However, I'm trying to display 4 separate sequences (each a subset of the original sequence) and there are 4 different formats (let's say Format1, Format2, Format3, and Format4).

I want to make it such that the 4 sequences will be randomly assigned one of the formats, without a format being repeated (for example, sequence2 with format1 followed by sequence4 with format2, sequence1 with format3, and sequence3 with format4).

I'm keeping track of these assignments by using an Embedded Data field for each of the formats. If sequence1 is assigned to format1, then the first Embedded Data field is set to 1 and so on.

I'm setting the values of the fields using JavaScript, however I'm not sure how to access these values in another page. For example, in the first page I set field1 equal to 1 (with setEmbeddedData()), but in the second page I don't know how to get the value stored in field1.

Note: This website shows a way to get those values but if you set the field in page 1, then you can't use the method described to access the data in page 2.


Solution

  • You can pipe the embedded data fields into subsequent pages:

    var sequence1 = "${e://Field/sequence1}";
    

    Also, note that you have to initialize the embedded variables in the survey flow before they can be set using setEmbeddedData().