Features 7 min read

Geo-Fencing QR Codes: Route Scans by City, State, or GPS Radius

Use IP geolocation to route QR code scans to different destinations based on the scanner's city, state, or proximity to a GPS coordinate.

A food truck chain prints identical QR codes on all its trucks. In Austin, the code shows the Austin menu. In Houston, the Houston menu. Same QR code, different content based on where it's scanned.

How Geo-Routing Works

When a QR code is scanned, ScanStack resolves the scanner's IP address to a geographic location. This gives us:

  • City — e.g., "Austin", "New York"
  • State/Region — e.g., "TX", "NY"
  • Latitude/Longitude — for radius-based matching
  • Country — for international routing

Three Geo Condition Types

City Matching:

{ "type": "city", "value": "Austin" }

State/Region Matching:

{ "type": "state", "value": "TX" }

GPS Radius:

{ "type": "geo_radius", "lat": 30.2672, "lng": -97.7431, "radius_km": 15 }

Uses the Haversine formula for accurate great-circle distance calculation.

Full Example: Multi-City Campaign

// Austin visitors
{ "conditions": [{ "type": "city", "value": "Austin" }],
  "target_url": "https://trucks.com/austin", "priority": 10 }

// Houston visitors
{ "conditions": [{ "type": "city", "value": "Houston" }],
  "target_url": "https://trucks.com/houston", "priority": 10 }

// Everyone else
{ "condition_type": "default", "target_url": "https://trucks.com/locations" }

Accuracy Considerations

  • IP geolocation is accurate to the city level for most urban areas
  • VPN users may appear in a different location
  • Mobile carrier IPs sometimes resolve to a regional hub
  • For radius matching, a margin of 10-20km covers most IP variance

Combine geo-fencing with time-based routing for "lunch in Austin" vs. "dinner in Houston" from a single QR code.