IP and GPS
What your IP gives away
What your IP gives away. The network's city arrives before you decide anything. A precise point waits. The map is the distance between those two ideas, and this lab stores neither.
Understanding the labHow to use it and why you'd want to
Why you'd want to
The city and coordinates already on the request are rounded to two decimals, and miles are measured to a browser point that stays in this tab. Neither point is stored.
How to use it
- The network point is the edge headers, rounded to two decimals.
- Ask for a browser point. It stays in this tab.
- The gap between the two points is measured here.
- Neither point is written to storage.
Map data © OpenStreetMap contributors. The dashed band around the network point is an illustration of city-scale error, not a measured radius.
The gap
—
Miles, once both points exist.
Share a browser point
The network already guessed. The precise point is optional, and it never leaves this tab. That is the difference consent makes: one place arrives unasked, the other waits.
What this request already carried
| Signal | Value | Use | Why |
|---|---|---|---|
| x-vercel-ip-city | Columbus | Used | Shown as the network's city. Not stored. |
| x-vercel-ip-country-region | OH | Used | Region from the same headers. |
| x-vercel-ip-country | US | Used | Country from the same headers. |
| x-vercel-ip-latitude | 39.96 | Used | Rounded to two decimals before it is drawn. |
| x-vercel-ip-longitude | -83.00 | Used | Rounded to two decimals before it is drawn. |
| x-vercel-ip-timezone | America/New_York | Used | The clock on the network's side of the request. |
| x-vercel-ip-postal-code | 43215 | Used | This is often finer than a city. This lab shows it and does not store it. |
| browser geolocation | — | Absent | Stays in this tab. It is not sent to the server. |
How it works
- The network point is already on the request: city, region, country, timezone, rounded coordinates, and sometimes a postal code.
- This lab draws that point and an illustrative 25-mile band. The band is not a measured error.
- A precise point starts only after the checkbox and the browser prompt.
- The line and the mileage are computed in this tab. The precise point is not sent.
- A wide gap usually means the network exits somewhere else: a VPN, a carrier gateway, or a corporate proxy.
The location lab traces where a stored beacon traveled. This page does not store one. It only compares the guess with a point you choose to keep local.
The distance stays local
Run this in the browser. Do not post the precise point.
function milesBetween(a, b) {
const R = 3958.8
const p1 = (a.lat * Math.PI) / 180
const p2 = (b.lat * Math.PI) / 180
const dLat = ((b.lat - a.lat) * Math.PI) / 180
const dLng = ((b.lng - a.lng) * Math.PI) / 180
const h = Math.sin(dLat / 2) ** 2 + Math.cos(p1) * Math.cos(p2) * Math.sin(dLng / 2) ** 2
return 2 * R * Math.asin(Math.min(1, Math.sqrt(h)))
}
// The network point is already on the request. The browser point stays here.
const gap = gps ? milesBetween(ip, gps) : nullWalkthroughHow we built itShowHide
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
The IP lab reads the city and the coordinates already on the request, rounds those coordinates to two decimals, and measures miles to a browser point that stays in this tab. Neither point is stored, and the lab does not call Adobe.
Read the edge headers
readIpDisclosure copies readEdgePlace and also returns the postal code. City, region, country, and timezone are decoded from the x-vercel-ip headers.
Round the network point
Latitude and longitude are rounded to two decimals. A pair outside the valid range is dropped, so the map has no network point.
Ask for a browser point
Share precise point runs only after the checkbox. getCurrentPosition uses enableHighAccuracy. The result is React state in this tab.
Measure the gap locally
milesBetween is the haversine distance in miles between the two points. The page draws that number. The browser point is not posted.
Leave the click untracked
The lab root is data-track-ignore. Nothing in this component calls trackLabEvent.
From the code
The network place. Coordinates are rounded to two decimals before they can be drawn.
export function readEdgePlace(source: HeaderSource): EdgePlace {
const latitude = headerNumber(source.get("x-vercel-ip-latitude"))
const longitude = headerNumber(source.get("x-vercel-ip-longitude"))
const roundedLat = latitude != null ? roundPlaces(latitude, 2) : null
const roundedLng = longitude != null ? roundPlaces(longitude, 2) : null
const pointOk = roundedLat != null && roundedLng != null && coordinatesInRange(roundedLat, roundedLng)
return {
city: decodePlace(source.get("x-vercel-ip-city")),
region: decodePlace(source.get("x-vercel-ip-country-region")),
country: decodePlace(source.get("x-vercel-ip-country")),
timezone: decodePlace(source.get("x-vercel-ip-timezone")),
latitude: pointOk ? roundedLat : null,
longitude: pointOk ? roundedLng : null,
postalPresent: Boolean(decodePlace(source.get("x-vercel-ip-postal-code"))),
}
}The miles between the network point and the browser point. The math stays in the tab.
export function milesBetween(a: { latitude: number; longitude: number }, b: { latitude: number; longitude: number }) {
const φ1 = (a.latitude * Math.PI) / 180
const φ2 = (b.latitude * Math.PI) / 180
const Δφ = ((b.latitude - a.latitude) * Math.PI) / 180
const Δλ = ((b.longitude - a.longitude) * Math.PI) / 180
const h = Math.sin(Δφ / 2) ** 2 + Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) ** 2
return 2 * EARTH_MILES * Math.asin(Math.min(1, Math.sqrt(h)))
}Google and Adobe
This lab does not queue its own event. The Google block shows an example of how you would track the interaction. Adobe is an example too.
This lab does not queue an analytics event of its own. After Accept, the site still queues virtual_page_view for the page, with page_path and page_title. Clicks inside a data-track-ignore region are not recorded. The push below is an example, not a call this page makes. This site does not call gtag('set') or Adobe.
Example only. This page does not push this object.
// Example only. This lab does not queue this event.
dataLayer.push({
event: "ip_gap_example",
miles: 12,
})Example implementation. This site does not call Adobe. eVar80, prop80, and event80 are example variable numbers. In Launch, a data element reads the value and a rule sends it when the value changes. In the report suite, enable eVar80 with Most Recent allocation and expire it on the hit. A processing rule is unnecessary if the data element maps straight to that eVar.
Example alloy payload. _example is a placeholder schema, not a real tenant.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
ipGap: "12 mi",
},
},
})Example hit. eVar80 is hit-scoped in this example. prop80 dies at the same hit.
s.eVar80 = "12 mi"
s.prop80 = "12 mi"
s.events = "event80"
s.linkTrackVars = "eVar80,prop80,events"
s.linkTrackEvents = "event80"
s.tl(true, "o", "ip_gap_example")Translation
Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Network city
GA4. Not sent. The city is read from the request and shown on the page.
Adobe. Example eVar80, expire on the hit.
Scope. Hit. A user property would keep this city after the visitor leaves.
Rounded coordinates
GA4. Not sent.
Adobe. Example prop80, which dies at the hit.
Scope. Hit. These are the request coordinates, not a user trait.
Miles between the points
GA4. Not sent. An example event parameter would be miles on ip_gap_example.
Adobe. Example event80 if you counted a comparison. Do not store the miles in eVar80.
Scope. Event. The distance is one comparison, not a visit property.
Browser point
GA4. Not sent. It stays in component state.
Adobe. Example: do not map a precise point to eVar80.
Scope. Not a hit. The point never leaves the tab.
Recommended next
Why these picksReading path transitions…