How to extract parts of embedded data field and save as new variable? | XM Community
Question

How to extract parts of embedded data field and save as new variable?

  • 19 April 2021
  • 4 replies
  • 172 views

Badge +2

Hello,
I am using the embedded data field "Q_URL", which stores the URL that the respondent used to participate in the survey, to monitor how many respondents I have for each target group (each target has its own url). The url contains hundreds of letters and digits, but in my link I am only interested in the last 6 digits in the URL. Is there a way to extract the last 6 digits of the Q_URL into a new variable in Qualtrics?
Thanks,
Timmy


4 replies

Userlevel 3
Badge +8

You could pull the embedded data into a javascript code to grab your requirement then save it as another embedded data variable.

Badge +2

Hi Pogi,
Yes I would assume that it takes javascript to solve it, however I don't know how to write it. Do you?
Thanks,
Timmy

Userlevel 3
Badge +8

I'm not a coder. I just search the web until I find something that looks like it will work and I try it.
Qualtrics uses jQuery by default. I found this resource that may help you get started.
How to Get Substring from a String Using jQuery (tutorialrepublic.com)
You will have use the javascript question API: Qualtrics JavaScript Question API - Qualtrics Question API
If you try something and it still doesn't work, you can post your code here and I can try to look it over.

Badge +2

Ok, thanks! I'll play around with it.

Leave a Reply