Deriving Domain Name from Email Address | XM Community
Skip to main content

I am looking to add a column/variable in Data And Analysis. The logic for this would be to simply extract domain name from email address provided during survey.

ex. testemail@qemailserver.com -- qemailserver.com

I couldn't find simple way to do that. I explored option to use embedded data and piped text.
${q://QID4/ChoiceTextEntryValue}
Is there a way to use any regular expression like substring to extract domain name while defining embedded data and piped text?
Found similar use case but custom java script is not showing up for my account like suggested here?
Screen Shot 2020-12-25 at 4.35.46 PM.png
https://www.qualtrics.com/community/discussion/3111/left-right-substring-extraction-functions-from-piped-text



String manipulations are not possible via the regular operations and adding javascript in questions is not available for free accounts. That's why you don't see the option to add custom JS.
You can look at adding the code with the

script 
tags in the header of your survey, that may work. However, you'll some extra logic to ensure that your embedded variables do not get overwritten.


Thanks Ahmed for your prompt response! Any reference how to add tags in header? Does this need custom JS?


https://www.qualtrics.com/community/discussion/comment/33152#Comment_33152That's a different question from what's mentioned in the title. So, I'd suggest asking a new question with as much details as you can provide and accepting the answer if the solution worked for you. This will allow other people to find answers more easily.


Sure! I can create a new thread. Does this option also need custom JS?

You can look at adding the code with the 

script 
tags in the header of your survey, that may work.


Don't create a new thread, I misunderstood your question about tags. Sorry. My fault. Suppose you want to use the JS code from the link in your initial question. So, this is how you'd go about it. Go to your header and select source. Ref:
image.pngThere you add a script tag, with . So, the final thing should look like:


Just be careful, because the problem is that this code will get executed on every page. So, if you are manipulating the questions and all, it may mess up some others also. However, if you are just going to store the data, then it shouldn't be a problem.


Thanks for the steps! I tried the same but seems like header is not getting saved. I am not able to verify that, every time I open the header after saving it reset to Blank.How will I ensure the code gets executed? Would this create an embedded variable a that can be used in data and analysis section?



Leave a Reply