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

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

  • December 17, 2019
  • 2 replies
  • 55 views

Forum|alt.badge.img+5
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

npetrov937
Level 2 ●●
Forum|alt.badge.img+4
  • Level 2 ●●
  • January 2, 2020
Have you tried using ${loc://CountryName} as embedded data value as opposed to Area Code: !

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 2, 2020
@cmbell, Create a JavaScript object keyed by abbreviation, then do a lookup: ``` var states = { ... "CO" : "Colorado", ... }; Qualtrics.SurveyEngine.setEmbeddedData("state",states['${loc://Region}']);