QR Code Conditional Routing: Send Users to Different Pages Based on Context
Set up conditional routing for QR codes based on device type, OS, location, language, and time. Complete guide with API examples.
One QR code, many destinations. Conditional routing lets a single QR code send users to different pages depending on their device, operating system, language, country, or time of day.
Why Conditional Routing Matters
Imagine printing QR codes on 10,000 product boxes. Without conditional routing, every scanner sees the same page. With it:
- iOS users → App Store
- Android users → Google Play
- Desktop users → Web landing page
- Spanish speakers → Spanish-language page
- Users in Japan → Localized Japanese site
Available Condition Types
Device Type: Route based on mobile, tablet, or desktop.
Operating System: Route based on ios, android, windows, macos, or linux.
Country & Language: Route based on the Accept-Language header or IP-derived country code.
Time of Day: With SmartRoute, define time windows for different content.
Geo-Fencing: Route by city, state, or GPS radius.
Setting Up a Rule via API
curl -X POST https://api.scanstack.dev/v2/qr/:id/rules \
-H "x-api-key: qr_your_key" \
-d '{ "condition_type": "os", "condition_value": "ios", "target_url": "https://apps.apple.com/app/your-app", "priority": 10 }'
Rules are evaluated in priority order (highest first). The first match wins. Always add a default rule as a fallback.
Compound Conditions (AND Logic)
Combine multiple conditions in a single rule:
curl -X POST https://api.scanstack.dev/v2/qr/:id/rules \
-H "x-api-key: qr_your_key" \
-d '{
"conditions": [
{ "type": "device", "value": "mobile" },
{ "type": "time", "start": "17:00", "end": "22:00" },
{ "type": "scan_count", "min": 2 }
],
"target_url": "https://example.com/mobile-evening-returning",
"priority": 20
}'
All conditions must be true (AND logic) for the rule to match.
Best Practices
- Always include a
defaultrule so unmatched scans still go somewhere useful - Use higher priority numbers for more specific rules
- Test your rules with different devices and browsers before printing
- Monitor scan analytics to verify rules are matching as expected