Rules

Rules decide where a scan goes. They’re checked from the top, the first match wins, and if none match, the scan goes to the main destination.

Rules are part of Premium and work on website and menu codes, and a menu’s rules apply to its tables. If a plan ends, printed codes keep working and go to their main destination, and the rules wait in case it comes back.

Setting rules

Build them on a code’s Rules tab, or send the whole list to PUT /qr/:id/rules. Include a rule’s id to keep its history, so your analytics stay connected across edits.

{
  "rules": [
    {
      "type": "time",
      "label": "Lunch",
      "conditions": {
        "start_time": "11:00",
        "end_time": "15:00",
        "days_of_week": [1, 2, 3, 4, 5],
        "time_zone": "America/Chicago"
      },
      "destination_url": "https://example.com/lunch"
    },
    {
      "type": "platform",
      "conditions": { "platforms": ["ios"] },
      "destination_url": "https://apps.apple.com/app/id000000"
    }
  ]
}

Types

time

Days and a window in a time zone. days_of_week runs from 0 (Sunday) to 6. A window that ends before it starts runs overnight, and its early hours belong to the day it began.

date

from and to as YYYY-MM-DD in a time_zone. Either can be left out.

device

devices: mobile, tablet or desktop.

platform

platforms: ios, android or other.

geo

countries: two-letter codes, worked out from the address of the scan.

language

languages: base codes such as es, matched to the first language the phone asks for.

param

A query parameter on the scanned link: key and optional values. Without values, any value matches.

split

percent from 1 to 99. Each visitor stays on the same side when they scan again.

Testing

“Test a scan” on the Rules tab shows where a scan would go, using the rules on screen, even before they’re saved. Nothing is recorded.

Results

Every scan records the rule that sent it. See totals on a code’s analytics, in by_rule from the analytics API, and in scan.rule on webhook events.

QR code redirect rules · PikaQR