humanmade / altis-analytics

Analytics module for Altis
https://www.altis-dxp.com/resources/docs/analytics/
GNU General Public License v3.0
9 stars 3 forks source link

Display country as human-readable country name #130

Closed rmccue closed 3 years ago

rmccue commented 3 years ago

Right now, the country field in the Audience builder exposes the raw country code, which requires people to know ISO codes off the top of their heads. We should show human-readable countries instead.

Under the hood, we want a way to map certain fields to more human-readable labels rather than the raw data (also for things like month and day eventually).

Since country names can be inconsistent, we should use existing data in WordPress where possible, and if needed, pull from the ISO standard.

Acceptance criteria:

shadyvb commented 3 years ago

So we decided to update the logic so:

Couple more things that pops up to mind:

cc @roborourke

roborourke commented 3 years ago

Agreed, if we can sort by count that'd be helpful to surface them to the top, maybe we'd use optgroups to separate them as presumably the sorting would switch to the provided order after that? Might be a bit confusing. I'd only show the count for the values we know - the terms aggregation I think gets the top 100 items for currently unless it's just the default 10 so there might be more values we don't know the count for that could be more than zero.

rmccue commented 3 years ago

Ordering by count would make the order unpredictable, so it might be a bit strange to hunt through the list to find your country only not to see it in the right place. e.g. the UK can appear alphabetically in selectors as "United Kingdom", "Great Britain" or in some cases "England", so people are used to hunting through for those. Making it harder to find that sounds even more painful.

The count in the label sounds good if possible; could we do something like United Kingdom (~22%), or is that not possible?

roborourke commented 3 years ago

That’s why I was thinking of splitting by optgroup, eg top hits and then everything else

rmccue commented 3 years ago

Does optgroup allow you to repeat the same value? 🤔 If so, I'm down with that

roborourke commented 3 years ago

Not really, it’s still one select so you can’t duplicate values. If it’s too complicated the simplest option is to show the raw count of uniques in the label. It’s not uncommon to see country drop downs with the most common options at the top though

shadyvb commented 3 years ago

As a tech user who should understand what the context of audiences / countries is, I'd probably find the most usable entries of a list at the top as a usable/expected feature. The optgroup is a nice adjustment so I'd understand why countries are sorted that way. Thinking from the point of view of the expected persona that'll use the feature.

And re count, we can calculate the percentage manually ( divide the number by the sum of all ), hoping that those numbers cover ALL visits otherwise the percentage wouldn't be correct, it does make more sense that absolute numbers.

shadyvb commented 3 years ago

Seems like repeating options in different optgroups is not uncommon, so win-win.

ref https://ux.stackexchange.com/questions/131836/are-duplicate-options-in-a-single-select-good-or-bad

WCAG doesn't say much about it: https://www.w3.org/TR/WCAG20-TECHS/H85.html, neither the spec: https://html.spec.whatwg.org/multipage/form-elements.html#the-optgroup-element

shadyvb commented 3 years ago

The new question would be whether we want to show ALL countries with any hits at the top, or only the top 10 or something, ideas ?

shadyvb commented 3 years ago

This is how it looks now: image.png

Note that I've limited the top hits entries to only 10, and they're also duplicate again with the rest of the options.

rmccue commented 3 years ago

@shadyvb Is this at odds with Rob's comment that you can't repeat values? I think this looks good provided that it's also alphabetical.

shadyvb commented 3 years ago

We can repeat values, yes. And the list is sorted by code rather than name, I'll update that to sort by name instead. Top hits will still be sorted by percentage though.

rmccue commented 3 years ago

This is how it looks now:

This looks great 👍

roborourke commented 3 years ago

Fixed in humanmade/aws-analytics#233

shadyvb commented 3 years ago

Found a bug with percentage calculation for non-preloaded list of values, addressed in https://github.com/humanmade/aws-analytics/pull/239/files