I want to record data from my custom Javascript Code | XM Community
Skip to main content

I think the Set embed data block should appear before the script executes like this assuming the script executes in Block 8:

I am unclear where to put the script to record the data. This is where I put it:

Qualtrics.SurveyEngine.addOnload(function()
{
    var qid = this.questionId;

    document.onkeydown = function(event) {
        console.log('keydown',event);
        if (event.which == 37) {
            event.preventDefault();
            Qualtrics.SurveyEngine.registryqid].setChoiceValue(1, true);
            jQuery('#NextButton').click();
        } else if (event.which == 39) {
            event.preventDefault();
            Qualtrics.SurveyEngine.registrytqid].setChoiceValue(2, true);
            jQuery('#NextButton').click();
        }
    }


});

Qualtrics.SurveyEngine.addOnReady(function()
{
    var qobj = this;
    setTimeout(function() { jQuery("#"+qobj.questionId+" .hideAfter45").hide(); },5000);


});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    `Qualtrics.SurveyEngine.setEmbeddedData('FIELD', value);`
`Qualtrics.SurveyEngine.getEmbeddedData('FIELD');`

});

 

Is this correct?

I have a series of questions that I want to capture the embedded data. Do I need a embed data block before each question or just one embed data block at the start of the series

Be the first to reply!

Leave a Reply