How to assign an embedded variable based on zip code? | XM Community
Skip to main content
I need to assign an embedded variable to each respondent based on the zip code they enter near the beginning of the survey. Ultimately every zip code across the state of Oklahoma would be assigned to one of 29 different districts that would need to be piped into the survey as an embedded field.



I think this can be accomplished using javascript, but I'm not sure how to go about doing this. Any help or advice would be greatly appreciated.
You can make an embedded data block at the beginning for each of your regions.



Then add the zipcodes comma separated, including commas before and after the block, like so



region1 = ,73078,73079,73080,

region2 = ,74253,74254,74255



Then after they enter the zip code, set a new embedded data like this:



zip_code = ,${e://piped/text/for/text/entry},



Now, make a branch for each region that looks like this:



if `region1` contains `zip_code` then

(within branch, set new embedded data as something like `region = region1`

Is there an easy way to a large amount of data into the block with the regions? If, for example, I wanted to import 4000 regions and their zip codes from a CSV to be used, where would I store it in qualtrics? Or do I have to do it by hand as in the example above?
Thanks so much!!


Leave a Reply