IP Geolocation for Content Localization
Suggest a regional experience while keeping the visitor in control
A regional store or product site can use approximate IP country data to offer a locale suggestion when a visitor has not chosen a region. Keep that suggestion separate from account settings, language preferences, and access-control decisions.
Implementation example by the EdgeDNS team · Updated
Location Is an Imperfect Hint
A network address does not identify a person’s residence, nationality, preferred language, or exact position. VPNs, shared networks, relay services, and incomplete lookup data make forced redirects brittle. Serving every locale only through IP-dependent content can also make alternate versions harder for search engines to discover.
Offer a Suggestion, Preserve Stable Locale Pages
Pass an explicit public visitor IP, obtained through your trusted server or proxy configuration, to IP Geolocation. Without an explicit visitor IP, a server-to-server lookup can describe your application server instead. Use country_code as an optional hint for a region selector, with a neutral experience when it is unavailable. The geolocation endpoint is available on Free; the separate IP Privacy check requires Developer and adds network-classification signals. Treat those classifications as fallible context, not proof of a visitor’s location or intent. The example below therefore requires Developer. Geolocation has a separate upstream lookup allowance, and results may be cached or have null fields; avoid a fresh call on every page view. Honor a visitor’s saved selection and offer a visible way to change it. Publish separate crawlable locale URLs and link between them rather than relying on automatic IP redirects. This workflow does not translate content, create hreflang markup, or implement geographic access enforcement. Use the internationalization reference to review the page’s locale annotations separately.
Endpoints Used
Combine these EdgeDNS endpoints to build this solution.
/v1/ip/geolocationAPI referenceIP Geolocation: Look up approximate country and network context for an explicit public IP.
/v1/ip/privacyAPI referenceIP Privacy: Review VPN, proxy, Tor, and hosting classifications before offering a regional suggestion.
What this workflow helps you do
Start with a country hint
Offer a regional choice when a country code is available, and retain a neutral default for unknown results.
Handle uncertain networks
Review privacy-network signals without turning a classification into a claim about a person.
Keep locales discoverable
Use explicit locale links and stable URLs so people and crawlers can reach every supported regional version.
Code Example
Collect a country suggestion and network context on your server
// Developer access is required for the optional privacy context used here.
// Replace this illustrative public IP with one resolved by your trusted proxy setup.
const visitorIp = '1.1.1.1';
const headers = { Authorization: 'Bearer YOUR_API_KEY' };
async function lookup(path) {
const url = new URL(path, 'https://api.edgedns.dev');
url.search = new URLSearchParams({ ip: visitorIp }).toString();
const response = await fetch(url, { headers });
const result = await response.json();
if (!response.ok) throw new Error(result.error?.message ?? 'Lookup failed');
return result;
}
const geo = await lookup('/v1/ip/geolocation');
const privacy = await lookup('/v1/ip/privacy');
console.log({
suggestedCountry: geo.data.country_code ?? null,
networkContext: privacy.data,
geoMeta: geo.meta
});
// Show a region selector; respect the visitor's existing choice.
// Do not infer language, force a redirect, or grant access from this hint alone.Learn More
Explore industry standards and best practices related to this use case.
Ready to build IP Geolocation for Content Localization?
Get started with 200 free API requests per month. No credit card required.
Other Use Cases
IP Threat Intelligence & Abuse Management
Combine IP reputation, privacy classification, and ownership context
SOC Analyst / Security OperationsSOC Alert Enrichment
Add domain and IP context to incident alerts
Fraud Analyst / Risk ManagerE-commerce Fraud Detection
Add domain and IP signals to transaction risk review