How to build an avatar through the survey | XM Community
Solved

How to build an avatar through the survey

  • 16 July 2019
  • 3 replies
  • 59 views

Badge
As part of our survey, we need our participants to build their own customized avatar, based on a set number of characteristics (e.g. face shape, skin color, hair length, etc). We have pre-built avatars for all possible combinations of these characteristics.

Is there a way to map a specific set of responses to a single image file (i.e. if a participant selects "oval face shape", "light skin", and "long hair", then the appropriate image with those features will be displayed)? There are over 600 finished avatars so ideally we are not doing this with a brute force method. Any suggestions are much appreciated!
icon

Best answer by TomG 17 July 2019, 03:41

View original

3 replies

Userlevel 7
Badge +27
If I were doing it, I would import the characteristics and image urls into a web database, then write a web service to lookup the image and return it as an embedded variable.

If you don't have the ability to do that, a second option would be to define a JS object with the all the characteristics and image urls. Then use JS to do the lookup.
Badge
@TomG Thanks for this suggestion!

I'm a complete novice when it comes to JS. I noticed you made a similar suggestion in another post with some sample code, which I thought may be adapted to this problem.

var zips = {
60606: "33",
etc. (999 more zip codes)
};

Let's say in Q.1, Q.2, and Q.3, participants select their different feature options (e.g. "oval", "light skin", "long hair"). In terms of defining the JS object, do I define it in reference to those 3 questions?

var avatar = {
"{q://QID1/Oval},{q://QID2/Light},{q://QID3/Long}" : "IM_7aFjemLktwT0S1f",
etc
};
Userlevel 7
Badge +27
> @akcooper said:
> @TomG Thanks for this suggestion!
>
> I'm a complete novice when it comes to JS. I noticed you made a similar suggestion in another post with some sample code, which I thought may be adapted to this problem.
>
> var zips = {
> 60606: "33",
> etc. (999 more zip codes)
> };
>
> Let's say in Q.1, Q.2, and Q.3, participants select their different feature options (e.g. "oval", "light skin", "long hair"). In terms of defining the JS object, do I define it in reference to those 3 questions?
>
> var avatar = {
> "{q://QID1/Oval},{q://QID2/Light},{q://QID3/Long}" : "IM_7aFjemLktwT0S1f",
> etc
> };
>
>

I think you want to put it in an array of objects, then user .filter()
```
var avatars = [
{ face: "oval", skin: "light", hair: "long", avatar: "IM_7aFjemLktwT0S1f" },
/* additional objects, all with the same keys (face, skin, hair, avatar) and different values */
];
```

Leave a Reply