Parsing/Separating URL Embedded Data Format | XM Community
Question

Parsing/Separating URL Embedded Data Format

  • 6 December 2023
  • 6 replies
  • 51 views

Userlevel 2
Badge +8

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!


6 replies

Userlevel 7
Badge +27

@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 = ["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]);
)};
});

 

Userlevel 2
Badge +8

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 = ["COURSEID", "COURSENAMEURL", "SITE", "COHORTDATE"];

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

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

    Qualtrics.SurveyEngine.setEmbeddedData(name, vals[i]);

  )};

});

Userlevel 7
Badge +27

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 = ["COURSEID", "COURSENAMEURL", "SITE", "COHORTDATE"];

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

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

    Qualtrics.SurveyEngine.setEmbeddedData(name, vals[i]);

  )};

});

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

Userlevel 2
Badge +8

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

Userlevel 2
Badge +8

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

 

Userlevel 7
Badge +27

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