03Tracking
Blocking rules
Filter collection by request context before events reach storage.
Blocking rules let you drop requests before they are stored, based on the page, referrer, client, and network of the request. Open a site's Settings page and find Blocking Rules.
Rule format
Each field takes one rule per line, and the rules for different fields are independent.
- A normal line blocks a match.
- Prefix a rule with
-to allow a match. - When several lines match, the last matching line wins, so you can block broadly and then add exceptions.
- Lines starting with
#are comments. - Use
*as a wildcard where the field supports it.
Use the Test button on each field to check a value against the current rules, including edits you have not saved yet. Use Help for the syntax of that field.
Fields
| Field | Rule syntax | Matching | Example |
|---|---|---|---|
| Domains | [-]hostname-glob | Page hostname, case-insensitive. | * then -example.com then -*.example.com |
| Paths | [-]/path-glob | Normalized URL path, case-sensitive. | /admin/*, -/admin/health |
| Query Parameters | [-]key-glob[=value-glob] | Case-sensitive; * in keys and values. Without =, any value of the key matches. | utm_*, -utm_source=trusted |
| Referrers | [-]hostname-glob | The referrer URL is reduced to its hostname; case-insensitive. | *.example.com, -trusted.example.com |
| User Agents | [-]text-glob | Against the request User-Agent, case-insensitive. | *bot*, -Googlebot |
| IP Addresses | [-]address, [-]CIDR, or [-]start..end | IPv4 and IPv6; ranges must be in the same family and ordered. | 203.0.113.0/24, -203.0.113.10..203.0.113.20 |
| ASNs | [-]number or * | Numeric autonomous system number from Cloudflare metadata. | 64500, -64501 |
| Countries / Regions | [-]ISO-3166-alpha-2 or * | Case-insensitive country code. | DE, *, -US |
| States / Provinces | [-]COUNTRY-REGION_CODE or * | Case-insensitive region code from Cloudflare metadata. | DE-BE, -US-CA |
Example: allowlist a set of domains
*
-example.com
-*.example.com
admin.example.comThis blocks every domain, then allows example.com and its subdomains, then blocks admin.example.com again.
Notes
- Rules can be tested only against a single value at a time. The result shows which lines matched and whether the final decision is Blocked or Allowed. If no rule matches, the field allows the value.
- Requests blocked by a custom rule appear in Request Observability with the reason for the rule type, for example blocked paths or blocked countries.
- Invalid rules cannot be saved. The editor shows which line is invalid.
- The country and region fields have a search button to find codes by name.