← Back to blog

IP Geolocation for Ad Targeting and Privacy

IP Geolocation for Ad Targeting and Privacy

IP geolocation for ad targeting means mapping a visitor's IP address to an approximate place, usually a country, region or city, so an ad system can decide which campaign to show. It works without cookies or device permissions, which is why it is popular, but it is also an estimate of where a network is, not a precise fix on a person.

The mechanics are simple. A request arrives, the ad server looks the address up in a geolocation dataset, and the result (country, region, city, sometimes a postal code) feeds targeting rules: show a store-opening promotion to people near the store, exclude regions where a product cannot legally be sold, or pick a currency and language for the creative. Because the IP address is already present in every request, no extra data needs to be collected from the user.

How accurate is IP-based ad targeting?

Accuracy is the first thing to be honest about. Country-level results are generally reliable. City-level results are weaker, and anything finer than a city is mostly guesswork, since the dataset describes where an address block is registered or routed, not which house a device sits in. Mobile traffic often exits through gateways that sit in a different city from the handset, and a corporate or university network may present one location for thousands of people. The reasons are covered in more depth in why city-level accuracy is limited.

For ad buyers this means geo rules should be written with slack. Targeting a 5 km radius from an IP-derived point wastes budget on people who are not there and misses people who are. Targeting a metro area or a country is far more defensible. If a campaign truly needs street-level precision, that has to come from something the user explicitly shares, such as browser geolocation with permission, rather than from the network address.

It also helps to check what the address actually belongs to before trusting its location. The ASN lookup shows which organization operates the network. If the owner is a hosting provider or a VPN service, the apparent location is the server's, not the viewer's, and a targeted impression is probably being spent on the wrong audience. On ipto, the /v1/ip response includes asn, org, is_datacenter and is_vpn next to the location fields, so you can discount those impressions in one call.

Privacy: is an IP address personal data?

In many jurisdictions an IP address can count as personal data, particularly when it is combined with other identifiers or retained over time. Europe's GDPR treats online identifiers this way in many contexts, and other regimes have comparable rules. The detail varies by country, so read the GDPR discussion of IP addresses and the overview of privacy laws across countries, and take legal advice for your own situation. Nothing here is legal advice.

What matters for design is that geolocation can be done in a way that keeps the footprint small. The location lookup itself does not require storing the address. A common pattern is to resolve the address at request time, keep only the coarse result (country or region), and discard the raw IP, or truncate it, before anything is written to logs or an analytics store. Practical steps that follow from that:

  • Resolve, then reduce. Store the country or region you need for targeting and reporting, not the full address or exact coordinates.
  • Set a retention limit. If raw addresses must be kept for security reasons, keep them separately from ad analytics and expire them on a schedule.
  • Respect consent signals. Where consent is required for personalized advertising, coarse geography used for contextual choices (such as language or currency) is a different purpose than building a profile, and the two should not be mixed in the same pipeline by accident.
  • Be transparent. Say in the privacy notice that approximate location is derived from the IP address and what it is used for.
  • Offer an opt-out wherever your obligations or your own policy call for one.

Filtering out traffic that should not be targeted

Ad budgets leak to non-human and masked traffic. Data-center addresses, Tor exits and known VPN endpoints do not represent a local audience. The VPN, Tor and proxy checker shows whether an address appears in ipto's threat-feed data, and the IP abuse checker reports corroboration across several feeds. Those feeds refresh every 6 hours, and the underlying IP and ASN datasets refresh daily. Two limits matter: the VPN, Tor and abuse flags currently cover IPv4 ranges only, so an IPv6 address returns false for them rather than a guess, and ipto does not detect residential proxies, so traffic routed through a home connection will look like an ordinary household.

A sensible policy is to treat those flags as a weighting signal. Exclude flagged addresses from audience reporting, do not bill location premiums for them, and keep a separate bucket in your analytics so you can see how much of a campaign they represent.

Trying it on ipto

Call GET https://ipto.to/v1/ip with no parameter to see the response for your own address, or use /v1/ip/:ip with any address to see its country, city, ASN and flags. The service is free with no signup and allows 1,000 requests per day, enough to test a targeting integration against real traffic samples. The full field list is in the API documentation.

The balanced approach is to use IP geolocation for what it does well, coarse and low-friction regional decisions, keep the data you retain to the minimum those decisions need, and be explicit with users about it. Precision you cannot actually deliver is not worth collecting extra data to chase.

Straight answers

Country-level results are generally reliable, city-level results are weaker, and anything finer is largely an estimate. The data describes where an address block is registered or routed, not the exact position of a device.
In many contexts an IP address can count as personal data, especially when combined with other identifiers or kept over time. The details depend on the jurisdiction and the use, so legal advice for the specific case is sensible.
Resolve the address to a coarse result such as country or region at request time, store only that result, and discard or truncate the raw IP before logging. Setting a retention limit and describing the practice in the privacy notice also helps.
← Back to blog