Geographic Targeting
Geographic targeting lets you limit an experiment to visitors from a specific country, or visitors whose browser is set to a particular language. Use it to run localized experiments, test country-specific promotions, or validate that a change works well for your largest markets before rolling it out globally.
Country targeting
A vs B can determine the country a visitor is connecting from. In the Audience Builder, add a condition of type Location. On screen the country condition is called Location, not Country. Then pick one or more countries from the list. You can use the Is operator to include specific countries or Is Not to exclude them.
Which countries you can pick
The Location condition lists every country and territory that has an ISO 3166-1 code. That is 249 in all. Type a name in the search box to find one fast.
Countries are identified by their two-letter ISO 3166-1 alpha-2 code. The Audience Builder shows country names for easy selection: you do not need to remember the codes.
Language targeting
Language targeting targets visitors whose browser language matches the value you select. This is determined by the visitor's browser language preference, not by geo-location. A visitor in Germany whose browser is set to English will match an English language condition, not a German one.
In the Audience Builder, add a condition of type Language and enter or select a language code. Common language codes:
en: Englishes: Spanishfr: Frenchde: Germanpt: Portugueseja: Japanesezh: Chineseit: Italiannl: Dutchko: Korean
The language value is read from navigator.language in the visitor's browser. This typically returns a two-letter code like en, but may sometimes include a regional variant like en-US or en-GB. A vs B matches on the primary language code (the part before the hyphen), so a condition for en will match both en-US and en-GB.
How geo data is fetched
The A vs B snippet only fetches geo data when it needs to. If at least one experiment on the page uses a Location condition, the snippet makes one lightweight request to the /v1/geo endpoint. This endpoint is served by A vs B's edge infrastructure, which works out the visitor's country from their IP address. If no experiment on the page uses a Location condition, the snippet skips this request entirely.
The snippet always waits for this request to finish before it checks any Location condition: there is no race where an experiment runs ahead of the lookup. If the request fails, for example because of a network problem, the visitor's country counts as unknown. A Location condition never matches an unknown country, so the visitor is not enrolled in that experiment.
The automatic country lookup described here applies to the Location condition on web-experiment audiences. Feature-flag projects have a separate, similarly-named country attribute, and nobody fills that one in for you: your own server code has to work it out and pass it in when it evaluates a flag. See Attributes for the feature-flag side.
Common use cases
Country-specific promotions
Testing a Black Friday banner for US visitors only? Add a Location condition of United States to your audience so the promotional variation is only shown to US traffic. Visitors from other countries continue to see the control.
Localized experiments
If you are testing translated copy for your French market, use a Location condition set to France (or a Language condition set to French, depending on which is more appropriate) to ensure only the right visitors see the French-language variation.
Regional rollout validation
Before rolling out a major change globally, run the experiment in a single region first. Target one or two countries to gather initial data and validate the change works as expected, then remove the country condition to expand to all visitors.
Combine country and language targeting for precision. For example, Location is Canada AND Language is French will target French-speaking Canadians specifically: useful if your site has a separate experience for Quebec.