Geographic Ad Targeting with IP Data
Target and measure ad campaigns by geographic location using IP geolocation intelligence.
Chapters
Chapters
Digital advertising depends on showing the right message to the right audience. Without geographic targeting, ad spend is wasted on users who cannot buy your product, are outside your service area, or live in a market where your offer is irrelevant. IP geolocation provides real-time geographic data at the moment an ad request is made — before the page even loads — enabling advertisers to target campaigns by country, region, city, or even postal code without relying on user-provided data or third-party cookies.
The Problem
As third-party cookies are phased out by major browsers and privacy regulations like GDPR and CCPA restrict behavioral tracking, advertisers are losing their traditional tools for audience targeting. Cookie-based targeting was already imprecise — cookies can be deleted, blocked, or shared across users on the same device. Mobile advertising faces similar challenges with Apple’s App Tracking Transparency reducing IDFA availability.
Meanwhile, advertisers still need to target by geography. A restaurant chain needs to show ads only within delivery range. A regional law firm cannot serve clients in other states. An e-commerce store needs to display local currency and shipping estimates. Without reliable geo-targeting, these advertisers either waste budget on irrelevant impressions or miss potential customers entirely.

How IP Intelligence Helps
IP geolocation resolves the visitor’s location at the network level — no cookies, no user consent for location sharing, no JavaScript required. When a user’s browser requests an ad, the ad server can query the IP address against a geolocation database and receive country, region, city, postal code, and timezone data in milliseconds. This enables several targeting strategies:
- Geographic targeting — serve ads only to users in specific countries, states, cities, or postal codes. Target a 50-mile radius around a store location without requiring the user to share their GPS coordinates.
- Localized messaging — dynamically insert the visitor’s city name, local phone number, or nearest store location into ad creative. “Free delivery in [City]” performs significantly better than generic messaging.
- Timezone-based scheduling — show breakfast restaurant ads in the morning and nightlife ads in the evening based on the user’s local timezone, not the server’s timezone.
- Competitive conquesting — target users near a competitor’s physical location with comparison ads or special offers.
- Compliance and exclusion — exclude regions where your product cannot be sold, where regulations prohibit certain advertising, or where you do not have distribution.
Key API Fields for Ad Targeting
The My IP Help API returns geographic and network data that maps directly to ad targeting parameters:
| API Field | Ad Targeting Use | Plan |
|---|---|---|
country_code | Country-level targeting and exclusions | Free |
region | State/province targeting for regional campaigns | Free |
city | City-level targeting and dynamic ad copy | Free |
postal_code | Hyper-local targeting, store radius campaigns | Pro |
latitude / longitude | Radius targeting around specific coordinates | Free |
timezone | Daypart scheduling based on local time | Free |
is_vpn | Exclude VPN users to improve targeting accuracy | Pro |
is_datacenter | Exclude bot traffic and datacenter IPs | Pro |
connection_type | Target residential users, exclude hosting/corporate | Business |
isp | ISP-level targeting for telecom campaigns | Free |
Implementation Example
A typical ad server integration queries the IP geolocation API on each ad request to determine which creative to serve. Here is a simplified example of how the targeting decision works:
// Server-side ad targeting logic
const geoData = await fetch(`https://api.myiphelp.com/v1/lookup/${userIP}`, {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}).then(r => r.json());
// Geographic targeting
if (geoData.country_code !== 'US') return fallbackAd;
if (!targetStates.includes(geoData.region)) return fallbackAd;
// Exclude non-human traffic
if (geoData.is_vpn || geoData.is_datacenter) return fallbackAd;
// Daypart targeting using local timezone
const localHour = getLocalHour(geoData.timezone);
const adSet = localHour < 12 ? morningAds : eveningAds;
// Dynamic creative with city insertion
const creative = adSet.find(ad => ad.radius
? haversine(ad.lat, ad.lng, geoData.latitude, geoData.longitude) < ad.radius
: true
);
return creative.render({ city: geoData.city });
This logic runs in milliseconds, well within the time budget of a typical programmatic ad auction. The API response can be cached per IP with a configurable TTL, so repeated ad requests for the same visitor during a session do not require additional API calls. For high-volume ad servers handling thousands of requests per second, this caching strategy keeps API usage predictable while maintaining targeting accuracy.
Real-World Targeting Scenarios
IP-based ad targeting applies across industries and campaign types:
Retail and Local Services
A restaurant chain with 200 locations uses postal code targeting to show ads only to users within a 10-mile delivery radius of each location. The ad creative dynamically inserts the nearest store address and current promotions. According to Google's research on local search, "near me" searches have grown consistently, and IP-based targeting captures this intent without requiring the user to search.
E-Commerce
An online retailer uses country and region data to display the correct currency, shipping costs, and delivery estimates in ad creative. Users in countries where the retailer does not ship are excluded entirely, saving ad spend. The connection_type field helps exclude datacenter and hosting IPs that generate impressions but never convert.
Travel and Hospitality
A hotel chain targets users by their current city to show "staycation" deals to locals and "visit us" campaigns to travelers in feeder markets. Timezone data enables scheduling beach resort ads during cold winter mornings in northern cities, when users are most receptive to warm-weather getaway messaging. VPN detection helps ensure targeting accuracy — a user connecting through a VPN in another country should not see locally targeted ads, as their apparent location does not reflect where they can actually book a stay. Combining city-level targeting with seasonal daypart scheduling maximizes both relevance and conversion rates.
Regulated Industries
Online gambling, alcohol, and pharmaceutical advertising face strict geographic regulations that vary by country, state, and sometimes city. A sports betting platform must only show ads in states where online gambling is legal — and must completely exclude users in prohibited jurisdictions. IP geolocation provides the compliance layer that ensures ads are never served in restricted areas, reducing legal risk and potential fines. The same approach works for age-restricted products, financial services advertising, and any industry where geographic regulations govern what can be promoted and where.
Improving Targeting Quality
Raw geographic targeting is only as good as the data quality. Several factors can reduce targeting accuracy:
- VPN and proxy users — users connecting through VPNs appear to be in the VPN server's location, not their actual location. The
is_vpnandis_proxyflags let you exclude these users from geo-targeted campaigns or apply broader targeting rules. According to DataReportal, over 30% of internet users worldwide use a VPN, making this filtering essential for targeting accuracy. - Mobile carrier NAT — mobile users may be geolocated to the carrier's NAT gateway rather than their actual position. City-level targeting is generally accurate, but postal code targeting for mobile users may be less precise.
- Corporate networks — employees connecting through corporate VPNs or proxy servers are geolocated to the corporate network's exit point, which may be in a different city or state from the employee's actual location.
- Bot and invalid traffic — datacenter IPs, known bot networks, and automated crawlers generate ad impressions that never reach real users. The
is_datacenterandis_botflags help exclude this traffic before ads are served, improving campaign ROI.
Why My IP Help
The My IP Help API is designed for the latency-sensitive requirements of ad serving. Key advantages for advertising use cases:
- Sub-millisecond response times — fast enough for real-time bidding (RTB) and ad auction environments where every millisecond counts
- Comprehensive detection flags — VPN, proxy, datacenter, and bot detection in the same API call as geolocation, eliminating the need for separate fraud detection services
- Postal code and coordinate data — enables hyper-local targeting without requiring GPS permissions or user consent
- Privacy-first approach — IP geolocation does not track individual users, does not use cookies, and does not require consent under most privacy frameworks, making it compliant with GDPR and CCPA requirements for geographic targeting
- Flexible integration — REST API with JSON responses integrates with any ad server, DSP, or custom bidder. Server-side lookups keep API keys secure and avoid client-side latency. Batch lookup endpoints support offline audience segmentation and campaign planning workflows.

Frequently Asked Questions
How accurate is IP-based geographic ad targeting?
IP geolocation is highly accurate at the country level (99%+) and reliable at the city level (70-85% depending on the region). Postal code accuracy varies more widely. For most ad targeting use cases, city-level accuracy is sufficient. Use VPN and proxy detection to filter out users whose location data may be inaccurate.
Can IP geolocation replace cookie-based targeting?
IP geolocation replaces the geographic component of cookie-based targeting. It tells you where a user is located but not their browsing history, interests, or demographics. It works well alongside contextual targeting (page content analysis) and first-party data to build effective campaigns without third-party cookies.
How does IP targeting work with VPN users?
VPN users appear to be located at their VPN server's position, not their actual location. The API's is_vpn flag identifies these users so you can exclude them from geo-targeted campaigns, apply broader targeting, or serve non-geographic ads instead. This improves targeting accuracy for the rest of your audience.
Is IP-based ad targeting compliant with GDPR?
IP geolocation for ad targeting is generally considered a legitimate interest under GDPR when used for geographic targeting without tracking individual users. IP addresses are personal data under GDPR, but geolocation lookups that return only geographic data (not user identifiers) typically fall under the legitimate interest basis. Consult your legal team for your specific implementation.
What is the API response time for real-time bidding?
The My IP Help API returns responses in under 50 milliseconds, well within the typical 100ms time budget for real-time bidding (RTB) auctions. Responses can be cached per IP to eliminate API calls for repeat impressions from the same user, further reducing latency.
Can I target ads by timezone using IP data?
Yes. The API returns the timezone field (e.g., "America/New_York") for each IP lookup. Use this to implement daypart scheduling — showing breakfast ads in the morning and dinner ads in the evening based on the user's local time, regardless of where your ad server is located.
How do I exclude bot traffic from my ad campaigns?
Use the is_datacenter and is_bot flags from the API to identify non-human traffic. Datacenter IPs, known bot networks, and automated crawlers generate impressions that waste ad budget. Filtering these before ad serving improves your click-through rate, conversion rate, and overall campaign ROI.
What is the difference between IP targeting and GPS targeting?
IP targeting determines location from the network connection and works without any user permission or device capability. GPS targeting uses the device's location sensor and requires explicit user consent. IP targeting is less precise (city-level vs street-level) but has universal coverage — it works on desktops, servers, IoT devices, and mobile devices even when location permissions are denied.
Can I do radius targeting with IP geolocation?
Yes. The API returns latitude and longitude coordinates for each IP. Use the haversine formula to calculate the distance between the user's coordinates and your target location (e.g., a store), then serve the ad only if the user is within your desired radius. This enables "near me" style targeting without requiring GPS.
How do I handle users whose IP location is wrong?
No geolocation method is 100% accurate. Build tolerance into your targeting — if you want to target a specific city, include the surrounding region as well. Use the VPN and proxy detection flags to identify users whose geolocation is likely incorrect. For campaigns where precision is critical, combine IP geolocation with other signals like language settings, timezone, or user-provided location.
Ready to get started?
Free plan includes 1,000 lookups/month. No credit card required.