# How to A/B test by country (geo-targeted experiments)

export const metadata = guideMeta("ab-testing-by-country");

Most stores and SaaS products don't sell to one market. Prices, shipping costs,
payment habits and even the words people respond to change from country to
country. A change that lifts conversions in Germany can do nothing in the US or
hurt sales in the UK.

A **geo-targeted A/B test** runs only for visitors from the countries you
choose. Everyone else sees your site as it is. This guide covers when to use one,
how to set it up in Testa, and the mistakes that most often make the results
unreliable.

## When to run a test by country

Use a country-targeted test when the change you want to test only makes sense,
or only matters, in some markets:

- **Localized pricing.** Test €49 against €45, or a charm price against a round
  one, for EU visitors only.
- **Shipping and delivery offers.** Free-shipping thresholds depend on what
  shipping costs you in each market.
- **Payment methods and trust signals.** Local payment badges (iDEAL, Klarna,
  BLIK), local reviews, or a "ships from the EU" message.
- **Messaging and positioning.** The same product may need a different value
  proposition in a market where you are the challenger rather than the leader.
- **Market-specific campaigns.** A regional sale or seasonal event, such as
  Singles' Day or Black Friday, that only runs in some countries.

If the change is meant for everyone, don't restrict it by country. Run it for all
traffic and break the results down by market afterwards, for example by
[sending experiment data to your analytics](/guides/subscribing-to-events).
Restricting the test reduces your traffic and makes it take longer to finish.

## How geo-targeting works in Testa

Testa detects each visitor's country automatically. You don't have to pass it in
yourself. Country is one of the **targeting rules** on an experiment, together
with device type and UTM parameters.

Three behaviors to know:

1. **Targeting is evaluated on the first page load.** Once a visitor qualifies
   and is assigned a variation, they stay on it for the rest of their visit,
   even if their browser state changes later.
2. **Rules on the same attribute combine with OR.** `Country is Germany` and
   `Country is Austria` means Germany *or* Austria.
3. **Rules on different attributes combine with AND.** A country rule plus a
   device rule means both must match, for example *German* visitors *on
   mobile*.

The [advanced targeting docs](/docs/experiment-setup/advanced-targeting) cover
the full rule reference.

## Step-by-step: set up a country-targeted test

### 1. Create the experiment

Create the experiment as usual. Geo-targeting works with both experiment types:

- **Edit HTML.** Change a price, a headline or a banner directly on the page.
  This works best for pricing and copy tests.
- **Split URL.** Send visitors to a different page, for example a localized
  landing page. See [split URL tests](/docs/experiment-setup/split-url-tests).

### 2. Add a country targeting rule

Open the experiment's **Advanced Settings** and add a targeting rule:

| Rule | Match type | Value |
| --- | --- | --- |
| Region (country) | is | Germany |

To include several markets, add one rule per country. Because rules on the same
attribute combine with OR, adding `Germany`, `Austria` and `Switzerland` creates
a DACH-only test.

### 3. Narrow it further if you need to

Add rules on other attributes to make the test more specific. For example:

- `Country is United Kingdom` **and** `Device is mobile`: UK mobile shoppers
  only.
- `Country is United States` **and** `UTM Campaign contains black_friday`: US
  visitors who came from your Black Friday campaign.

### 4. Exclude anyone who shouldn't count

Use **exclusion rules** to keep internal traffic and irrelevant pages out of
the test. For example, exclude a URL containing `/admin`, or exclude visitors
who have a `staff` cookie. A visitor who matches any exclusion is left out, even
if they pass targeting.

### 5. Set traffic allocation and launch

Choose what share of *eligible* visitors enters the test and how they are split
between variations. If only 20% of your traffic comes from the target country,
a 50/50 split is applied to that 20%. See
[traffic allocation](/docs/experiment-setup/traffic-allocation) for how the two
percentages multiply.

## Three common geo test setups

### Localized price test for one market

You want to know whether the Polish market converts better at a lower local
price.

- **Targeting:** `Country is Poland`
- **Type:** Edit HTML. Change the displayed price on product and pricing pages.
- **Goals:** purchase (custom event with order value), plus add-to-cart as a
  supporting metric.

> **Keep prices consistent**
>
> If you test a displayed price, make sure checkout charges the same amount. A
> mismatch between the price on the page and the price at checkout destroys trust
> and can create legal problems with consumer law. Use your platform's market or
> currency pricing so the price is right all the way through checkout.

### Free-shipping threshold for the UK

- **Targeting:** `Country is United Kingdom`
- **Control:** "Free shipping over £60"
- **Variation:** "Free shipping over £40"
- **Goals:** purchase *and* average order value. A lower threshold usually
  raises conversion rate and lowers basket size, so you need to see both.

### Run everywhere except one market

Sometimes a market has its own pricing or a running campaign you don't want to
disturb. Use the **is not** match type: `Country is not United States`.

## Mistakes that skew geo test results

**Splitting traffic too thin.** Every country rule removes visitors from the
test. Before you launch, estimate how long the test needs with the
[sample size calculator](/calculator), using that country's traffic and
conversion rate, not your global numbers. If the answer is "four months",
test a bolder change or target a group of similar markets together.

**Mixing currencies in revenue goals.** If a test covers several countries with
different currencies, sending order totals without a currency mixes euros and
pounds into a single number. Send the currency with each purchase event, or
keep revenue tests to markets with a single currency.

**Running overlapping market tests.** If an EU-wide test and a Germany-only test
change the same pages, German visitors can end up in both, and you can't tell
which change caused the result. Make them
[mutually exclusive](/guides/running-mutually-exclusive-tests).

**Ignoring travelers and VPNs.** Country detection works for the vast majority
of visitors, but people on a VPN or traveling abroad will sometimes be counted
in the wrong market. This is noise, not bias. It affects control and variation
equally, so it won't change the winner, but don't expect a perfectly "pure"
country sample.

**Calling the test too early.** Smaller markets reach significance slowly, and
weekly cycles (weekend versus weekday shopping) matter more when traffic is
low. Run for at least one, and preferably two, full weeks.

## FAQ

### Can I target several countries in one experiment?

Yes. Add one `Region (country) is …` rule per country. Rules on the same
attribute combine with OR, so the experiment runs for visitors from any of them.

### Can I exclude a single country instead?

Yes. Use the **is not** match type, for example `Country is not Germany`.

### Does the visitor switch variations if they change country mid-visit?

No. Targeting is evaluated on the first page load, and the visitor keeps their
assigned variation from then on.

### Do I need to send country data from my site?

No. Testa detects the country automatically. You only add the targeting rule in
the dashboard.

### Should I run one global test or separate tests per country?

Run one global test when the change makes sense everywhere, and break the
results down by market in your analytics. Run separate country tests when the variation itself is
market-specific, such as a local price, a local offer or translated copy.
