Embedded data - persisting to end of survey | XM Community
Solved

Embedded data - persisting to end of survey


Userlevel 2
I have developed a survey in qualtrics where the questions include some interactive experiences. I developed the interactive experiences within qualtrics using css, html and javascript. Now I want to collect backend data about the usage of various interactive elements as the users are going through the survey. I can successfully collect the backend information within a given question. However, I cannot get the values that I have collected to persist to the end of the survey. I have tried using embedded data and overwriting the timing variables but I cannot get the values that I set (using the qualtrics setter function) to persist to the end of the survey. I am happy to post my code but this seems like a pretty straightforward use of the embedded data. Does anyone have any suggestions? Thanks for any help!
icon

Best answer by mattyb513 10 July 2018, 16:51

View original

26 replies

Userlevel 7
Badge +27
@leventha - Post the code. Otherwise, we would just be guessing.
Userlevel 2
html:
Sample Page
<p>Sample Paragraph</p>

<p id="demo1">Sample</p>

<p> </p>
Userlevel 2
See above. Sorry that I did not comment when posted. Basically, I am trying this with the most minimal code. As you can see from the xml data export, the embedded data does not retain the value of the timing var that was assigned to it. Thanks!
Userlevel 7
Badge +6
@leventha - Could you not create embedded data that explained which experience they had?
Userlevel 6
Badge +6
@leventha your code appears to be missing here. Make sure you surround it by three backticks so that it doesn't swallow it up in the markdown abyss.
Userlevel 2
Hi - Thanks for your comment. I am working with Qualtrics support as my code is kicking out some "access denied" problems. Neither backticks nor marking the text as "code" is working. I will post the code as soon as the problem is resolved.

Meanwhile if anyone wants to think about this...What appears to happen is this -> I assign my embedded data var a value on a question. On exit of the survey, it appears that some kind of deconstructor for the embedded data object reverts the value to null.

If you are interested in the code, I will try to attach a file in the next post.
Userlevel 6
Badge +6
@leventha Try creating a gist on github and posting the URL instead
Userlevel 6
Badge +6
Are you trying to access it on the end of survey page?
Userlevel 2
see file
Userlevel 2
Yes. I need the embedded data *after* the end of the survey. I built a number of interactive experiences, embedded within the qualtrics questions. I did not include the interactive experiences in the above code but the above code illustrates the problem. I need to basically collect the "clickstream" of the interactive experiences. I have the experiences working and the collection of the clickstream into embedded data vars. Now I just need to get the embedded data vars to persist at the end of the survey.
Userlevel 6
Badge +6
Hard to tell - I'm not seeing the same behavior. https://qualtricssfi.az1.qualtrics.com/jfe/preview/SV_727LdOGIiKDAtBX?Q_SurveyVersionID=current&Q_CHL=preview

Are you sure you are actually setting the data? On one of the pages following it being set, check the data in the console by doing `Qualtrics.SurveyEngine.getEmbeddedData('edName');`

Does it return null? If so, you likely aren't setting your data correctly.

Also, is the survey running on JFE? As in, do you see `/jfe/` in the URL or `/SE/`?
Userlevel 6
Badge +6
I just exported your file and I see the issue - You are setting it incorrectly. You are doing this:

```javascript
Qualtrics.SurveyEngine.setEmbeddedData( '{e://Field/demo1InnerHTML}', '');
```

but it should be

```javascript
Qualtrics.SurveyEngine.setEmbeddedData( 'demo1InnerHTML', '');
```
Userlevel 6
Badge +6
Note that I omitted the `$` in yours because I kept getting Access Denied errors when trying to post. It's not necessary anyway
Userlevel 2
I will check on the jfe. Yes the data is set via the setter function. Did you actually run the code and then dump the data after the completion of the survey?
Userlevel 2
Wow thanks! I will try this and see if it works.
Userlevel 6
Badge +6
> @leventha said:
> I will check on the jfe. Yes the data is set via the setter function. Did you actually run the code and then dump the data after the completion of the survey?

No, but I know it won't work because you are setting the ED incorrectly as stated above.
Userlevel 2
I tried your solution of using only the limited name for the var and the value . When I dumped out my values at the end of my survey, the value of demo1InnerHTML was still null. Were you able to dump out a value at the end of your survey that you had set within the survey to this var?
Userlevel 6
Badge +6
Export your survey as a qsf and post it. It’s in the Survey Options
Userlevel 2
exported survey attached
Userlevel 6
Badge +6
There are several problems here.

First off, you can't access `${q://QID18/ChoiceNumericEntryValue/3}` while on the same page as that question. You need to be on the next page.

Additionally, you can't access that value using the `getEmbeddedData` method as it's not embedded data. You would instead reference it in quotes and allow Qualtrics to fill that value for you on page load. However, that only works on page load, so again, you can't get that value on the page it's set.

Finally, any of these errors could be caught by using `console.log`s to find that nothing was being set even on that page. I suggest that you spend a bit more time debugging using logging in order to narrow the scope of your issue.
Userlevel 2
OK. For my real project, I am setting the values of the embedded data directly. I was just trying to play with the other "predefined" data because I thought that it might be more persistent. Even when I set my user defined embedded data, I cannot get it to persist past the end of the survey. For example, let's suppose that I use the setter function to set my embedded data value to 17, when the survey ends, my embedded data value is reset to null.

This is why I hypothesize that there is a deconstructor for the embedded data object that resets it to null on close of survey. Is there a workaround?

I will post an example of an explicit set of embedded data to a literal to demonstrate that the value is not persistent after the end of the survey.

Thanks for all feedback!
Userlevel 2
Here is a simple example of the problem.
Userlevel 6
Badge +6
> @leventha said:
> OK. For my real project, I am setting the values of the embedded data directly. I was just trying to play with the other "predefined" data because I thought that it might be more persistent. Even when I set my user defined embedded data, I cannot get it to persist past the end of the survey. For example, let's suppose that I use the setter function to set my embedded data value to 17, when the survey ends, my embedded data value is reset to null.
>
> This is why I hypothesize that there is a deconstructor for the embedded data object that resets it to null on close of survey. Is there a workaround?
>
> I will post an example of an explicit set of embedded data to a literal to demonstrate that the value is not persistent after the end of the survey.
>
> Thanks for all feedback!

There is no deconstructor, my example above shows that
Userlevel 2
OK if there is no deconstructor, then that is not the source of the problem. The problem still remains that given the code that I posted (attached above - no choice but a different discussion) will not set the embedded data var to a value that persists at the end of the survey. In my case, in which I built a user-defined interaction into the qualtrics question, it is essential that I collect backend user performance data from the my specialized interaction. Unlike many other examples where the user links to an outside website and then is redirected back to qualtrics, it is essential for our experiment to actually embed the interaction into the qualtrics question. I have successfully built the interactions that we need for our experiment but I must also be able to grab this backend data. Getting the data itself is straightforward. But I can't assigned the backend data to an embedded data variable and get the embedded data var value to persist to the end of the survey.
Userlevel 6
Badge +6
In this qsf you have posted the same things are still incorrect.

Here is a gist showing the revisions between yours and mine. This should answer any residual questions you have: https://gist.github.com/mattbloomfield/51d75c2961f7025f7f8654bcdb3d27f3

To recap:

* When setting embedded data, just use the name, not the code
* You can't use embedded data functions for anything except embedded data
* Piped text is only available on page load
* Don't use the unload function to set data on page turn, instead listen for the NextButton click.

Leave a Reply