Nearby
Who is near me right now
Who is near me right now. Only people who opt in, and only as a one-mile cell. The map never draws a person. A cell with fewer than three people stays hidden, and the row expires.
Understanding the labHow to use it and why you'd want to
Why you'd want to
An opt-in point is snapped to a one-mile cell, and a cell is published only when at least three people share it. Rows expire after 30 minutes.
How to use it
- Opt in before a point is snapped to a cell.
- A cell with fewer than three people stays hidden.
- Your own hidden count can still be shown to you.
- A row is gone 30 minutes after it was written.
Map data © OpenStreetMap contributors. Circles are one-mile cells, not people. A faint circle is closer to expiring.
Within this distance
—
Live people in published cells within 10 miles. Cells under 3 are not included.
Sample people within 10 miles: 24. The sample cell of 2 is hidden and not counted.
Count me in
The precise reading chooses a one-mile cell and is then dropped. This browser sends the cell center, a random token, and nothing else. The row expires 30 minutes after the last check-in.
The map starts from the coarse place on this request: Columbus, OH, US. You are not on it until you opt in.
How it works
- You check the box. The browser then asks for a point.
- The page snaps that point to a one-mile cell and drops the precise reading.
- A random token in this browser is the only id. It is not the visitor cookie.
- The row expires 30 minutes after the last check-in. Remove me deletes it now.
- A cell appears on the map only when three people share it. The radius count uses those same cells.
Live rows need the nearby_presence table. Apply drizzle/0015_nearby_presence.sql. Until then the page says so and keeps the labeled sample.
Snap, then forget the point
The cell is what gets stored. The point does not.
// Snap to a one-mile cell. Keep the cell. Drop the point.
const MILES = 69
function snap(lat, lng) {
const latStep = 1 / MILES
const latIndex = Math.round(lat / latStep)
const snappedLat = latIndex * latStep
const lngStep = latStep / Math.max(0.2, Math.abs(Math.cos((snappedLat * Math.PI) / 180)))
const lngIndex = Math.round(lng / lngStep)
return { cell: latIndex + ":" + lngIndex, lat: snappedLat, lng: lngIndex * lngStep }
}Publish a cell at three
The radius count uses the same filter, so a hidden cell cannot be inferred from the total.
// A cell is a place on the map only when three people share it.
const visible = cells.filter((cell) => cell.count >= 3)
const within = visible
.filter((cell) => milesBetween(center, cell) <= miles)
.reduce((sum, cell) => sum + cell.count, 0)WalkthroughHow we built itShowHide
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
The nearby lab snaps an opt-in point to a one-mile cell and publishes a cell only when at least three people share it. Rows expire after 30 minutes, and the lab does not call Adobe.
Snap the point to a cell
snapToCell rounds latitude to a one-mile step and longitude by the cosine of that latitude. The browser posts the cell, not the raw point.
Require opt-in
The POST is refused unless consent is opt-in. Global Privacy Control returns 403 and the page deletes the local token.
Hide a cell under three people
summarizeNearby groups rows by cell. A group with fewer than K_ANONYMITY people is omitted from the map and from the radius count. Your own hidden count can still be shown to you.
Expire the row
A presence row lasts 30 minutes. The page polls every 20 seconds and refreshes an opt-in cell about every two minutes while the tab is visible.
Draw a labeled sample
sampleNearby fills the map when live cells are hidden. The lab component does not call trackLabEvent.
From the code
The raw point becomes a one-mile cell. Longitude steps shrink toward the poles.
export function snapToCell(latitude: number, longitude: number): Cell {
if (!coordinatesInRange(latitude, longitude)) throw new Error("coordinates")
const latStep = CELL_MILES / MILES_PER_DEGREE
const latIndex = Math.round(latitude / latStep)
const snappedLat = round5(latIndex * latStep)
const cos = Math.cos((snappedLat * Math.PI) / 180)
const lngStep = latStep / Math.max(0.2, Math.abs(cos))
const lngIndex = Math.round(longitude / lngStep)
return cellFromIndex(latIndex, lngIndex, snappedLat, lngStep)
}A cell under three people is skipped. The radius count uses only the published cells.
for (const group of groups.values()) {
const remaining = group.updatedAt + PRESENCE_TTL_MS - now
const minutesLeft = Math.max(0, Math.round(remaining / 60000))
const hidden = group.count < K_ANONYMITY
if (selfToken && group.tokens.includes(selfToken)) {
you = { count: group.count, hidden, expiresAt: group.expiresAt, minutesLeft }
}
if (hidden) continue
cells.push({
latitude: group.latitude,
longitude: group.longitude,
count: group.count,
fade: clamp01(remaining / PRESENCE_TTL_MS),
minutesLeft,
})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: "nearby_cell_example",
cell_count: 3,
})Example implementation. This site does not call Adobe. eVar85, prop85, and event85 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 eVar85 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: {
cellCount: "3",
},
},
})Example hit. eVar85 is hit-scoped in this example. prop85 dies at the same hit.
s.eVar85 = "3"
s.prop85 = "3"
s.events = "event85"
s.linkTrackVars = "eVar85,prop85,events"
s.linkTrackEvents = "event85"
s.tl(true, "o", "nearby_cell_example")Translation
Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Cell count
GA4. Not sent. The map shows a count only when the cell has at least three people.
Adobe. Example eVar85, expire on the hit.
Scope. Hit. A user property would keep a count after the row expires.
Radius miles
GA4. Not sent. The slider changes the query.
Adobe. Example prop85, which dies at the hit.
Scope. Hit. The radius is a view control, not a visit trait.
Opt-in token
GA4. Not sent. The token stays in localStorage and is posted only to /api/lab/nearby.
Adobe. Example: do not copy the token into eVar85.
Scope. Not an analytics user. The token identifies a row on this site.
Hidden cell
GA4. Not sent.
Adobe. Example prop85 if you recorded that your own cell was hidden.
Scope. Event. Hiding a cell is a result of this read, not a user property.
Recommended next
Why these picksReading path transitions…