Code to change piped GeoIP state data from abbreviation symbol (e.g. CO) to word (e.g. Colorado)? | XM Community

Code to change piped GeoIP state data from abbreviation symbol (e.g. CO) to word (e.g. Colorado)?

  • 17 December 2019
  • 2 replies
  • 14 views

Badge +3
Hi

I am using the GeoIP data in the instruction text of a survey, to suggest that the events occurred in the respondent's state. However the GeoIP data is in abbreviation form rather than the proper names. I am not at all proficient in coding. Searched github but can't find anything. Anyone able to share some javacript for this?!

Thanks!
Chris

2 replies

Userlevel 4
Badge +4
Have you tried using ${loc://CountryName} as embedded data value as opposed to Area Code:
!
Userlevel 7
Badge +27
@cmbell,

Create a JavaScript object keyed by abbreviation, then do a lookup:
```
var states = {
...
"CO" : "Colorado",
...
};
Qualtrics.SurveyEngine.setEmbeddedData("state",states['${loc://Region}']);

Leave a Reply