Learning center

A bug only users in one country see: what geolocation emulation does not change

When a bug only reports in from one country, two different mechanisms can explain it, and the tools that emulate location only reach one of them. The browser's Geolocation API reports coordinates the page asks for. The server, CDN and third-party scripts decide from the request's IP address. Emulating coordinates in DevTools or Playwright changes the first and leaves the second at the maintainer's real location.

Two kinds of location#

Location sourceRead byChanged by DevTools Sensors or Playwright geolocation
Geolocation API (navigator.geolocation)Page scripts, after the user grants permissionYes
The client's IP addressServers, CDNs, consent tools, payment and ad scriptsNo
Locale and time zonePage scripts, and the server through Accept-LanguageNo, but they can be set separately
The account's country settingThe applicationNo: it is data

Playwright's geolocation option, used with the geolocation permission, sets the coordinates the page receives. Codegen's --geolocation does the same. Playwright: Geolocation

Find which one the bug depends on#

Look at the request and response, not only the page.

  • The response differs by country. A CDN or edge rule adds a header such as a country code, a redirect to a country site, or a different price list. Compare the reporter's document response headers with yours.
  • A third-party script behaves differently. Consent banners, payment methods and tax calculation often depend on the visitor's IP country. The script's own requests in the Network panel show what it decided.
  • The page asks for coordinates. A store locator or a delivery-area check that calls navigator.geolocation. Emulating coordinates reproduces this one.
  • The locale is what differs. Users in one country share a language and time zone. Often the "country bug" is a locale bug.

Reproduce an IP-based decision#

You cannot change your IP's country with a browser setting. Options, from cheapest:

  1. Ask the server which country it saw. If the CDN sets a country request header for the origin, log it, or have a debug endpoint return it.
  2. Override it in a non-production environment, such as a query parameter or a header the edge honors in staging only.
  3. Replay the response. If the bug is in how the page handles a country-specific response, record that response and serve it back.
  4. Test from that region with infrastructure your organization already has there, such as a CI runner or a cloud VM in that region.

Record the country the server saw, not only the country the user was in. VPNs, corporate proxies and mobile carriers often route traffic through another country.

Worked example: a payment option missing in Austria#

This example is fictional. Users in Austria report that the "Pay by invoice" option is missing. A developer in Germany emulates Vienna's coordinates with DevTools Sensors and still sees the option.

The Austrian user's Network panel shows the payment provider's configuration request returning methods without invoice, and its response includes "country": "AT", derived from the IP address. The geolocation emulation never reached that request. The developer replayed the provider's Austrian response with routeFromHAR and saw the missing option; the provider's dashboard showed invoice payments enabled only for Germany. A configuration change fixed it.

Questions#

Does the Sensors panel change the time zone too?

The Sensors panel has separate settings for the location, the time zone and the locale. Set each to match the reporter, since a preset city does not imply them.

Is a VPN a valid way to reproduce?

It can be, if your organization permits it, and it does change the IP country. Record the exit country and treat it as an approximation: some services detect VPN addresses and treat them differently.

Is the user's country personal data?

On its own it is coarse. Combined with other details it narrows down a person. Record what the reproduction needs.

Return to reproducing what someone else saw for the other layers a replay needs.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading