Parsing/Separating URL Embedded Data Format | XM Community
Skip to main content

Hi all!  I have embedded data that is coming over from a vendor (using the URL embedded process).  It comes in one long string of data.  I need this data parsed out to use in the dashboards as filters or widgets.   Here is an example:  

Z-ABCD-89_new_associate_sno_8-30-2023 

This is the response I have when a user takes a survey.  I need 4 different columns of data from this response.  Using the example above here are the 4 different data columns needed - All separated by “_” (although the course name may cause issues as it underscores spaces in the name) 

  • “Z-ABCD-89” is the course id
  • “new associate” is the course name
  • “sno” is the site / location
  • “8-30-2023” is the Cohort Date

How can I parse this out?  I have tried looking at other posts, but they seem a bit different than what I need.  A lot of solutions are JavaScript (which I’m not too familiar with but can try and figure out).  Any suggestions on how I can get this data parsed out after it’s passed over in a survey embedded field?  Any help you can provide will be greatly appreciated!  Thanks in advance for your time!

@AMLS

You’ll need to use JS.

First, define the embedded data fields in the survey flow: classId, courseName, location, cohortDate.

Then JS attached to a question (Assuming no underscores in course name. Underscores in course name could be handled, but it would be much more complex):

Qualtrics.SurveyEngine.addOnload(function() {
var fields = l"classId", "courseName", "location", "cohortDate"];
var vals = "${e://Field/vendorString}".split("_"); //replace vendorString with correct name
jQuery.each("fields", function(i,name) {
Qualtrics.SurveyEngine.setEmbeddedData(name, vals,i]);
)};
});

 


Thanks TomG.  I will try and work with JS.  I don’t know this language however there may be someone here who does. Right now it’s throwing an unexpected token message….all the fields are spelled correctly, so unsure what it is.  I will see if someone here can help.  Thanks again. 

 

What I’m using below for reference only using my embedded info.  

 

Qualtrics.SurveyEngine.addOnload(function() {

  var fields = p"COURSEID", "COURSENAMEURL", "SITE", "COHORTDATE"];

  var vals = "${e://Field/CATALOG_ID}".split("_");

  jQuery.each("fields", function(i,name) {

    Qualtrics.SurveyEngine.setEmbeddedData(name, valsEi]);

  )};

});


Thanks TomG.  I will try and work with JS.  I don’t know this language however there may be someone here who does. Right now it’s throwing an unexpected token message….all the fields are spelled correctly, so unsure what it is.  I will see if someone here can help.  Thanks again. 

 

What I’m using below for reference only using my embedded info.  

 

Qualtrics.SurveyEngine.addOnload(function() {

  var fields = p"COURSEID", "COURSENAMEURL", "SITE", "COHORTDATE"];

  var vals = "${e://Field/CATALOG_ID}".split("_");

  jQuery.each("fields", function(i,name) {

    Qualtrics.SurveyEngine.setEmbeddedData(name, valsEi]);

  )};

});

Oops, “fields” shouldn’t be in quotes inside the .each function.


Thanks for reviewing Tom.  Same result (error message) when I remove the quotes.  


Ah! We had the brackets and parathesis in the wrong order...🤞  Hoping it works now. 

 


This code works:

Qualtrics.SurveyEngine.addOnload(function() {
var fields = ["COURSEID", "COURSENAMEURL", "SITE", "COHORTDATE"];
var vals = "${e://Field/CATALOG_ID}".split("_");
jQuery.each(fields, function(i,name) {
Qualtrics.SurveyEngine.setEmbeddedData(name, vals[i]);
});
});

 


Leave a Reply