Set Count of Group as Embedded Data in PGR | XM Community
Skip to main content

Hi there :)
After working on this for a couple of hours with no avail - I figured I'd ask!
I am looking to set the count (number of dragged responses) in a particular group (I have 3 total groups) as an embedded data variable.
Does anyone have any ideas?

Thanks in advance!
j

Hi Jmaca,
You need to add your embedded data variables (e.g. Group1Count, Group2Count, Group3Count) in the survey flow before the Pick, Group, Rank question.
Then you can add the following jQuery code to your Pick, Group, Rank question -:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
    var that = this;
    if(type == "next")
    {
        Qualtrics.SurveyEngine.setEmbeddedData("Group1Count", jQuery("#" +that.questionId+"group0 li").length);
        Qualtrics.SurveyEngine.setEmbeddedData("Group2Count", jQuery("#" +that.questionId+"group1 li").length);
      Qualtrics.SurveyEngine.setEmbeddedData("Group3Count", jQuery("#" +that.questionId+"group2 li").length);
    }
});
You will then be able to pipe/reference the embedded data variables as needed from the next page.
Credit really goes to rondev for this solution.


Amazing! Thank you so much.

Just a quick follow-up. It doesn't look like I am able to go and change an answer with the embedded value being updated. Do you know if that is possible?

And it also seems to only be working about 50% of the time...could that be a factor of my poor internet?

Thanks!

Jess


Leave a Reply