Url Rules
A URL rule answers “does this page count?” Everyday meaning: a yes/no check against the address in the browser. In CROForge, rules are used for experiment Pages (where a campaign may run) and inside segment or metric conditions when the data type is URL.
Include means “this page is allowed.” Exclude means “this page is blocked even if an include also matches.” Combined logic is includeMatch && !excludeMatch.
Words used on this page
| Word | Everyday meaning | Meaning in CROForge |
|---|---|---|
| URL | The full address of a page | The value targeting compares after it is cleaned |
| Origin | https:// plus host (and port if any) | Kept in the cleaned string, for example https://example.com |
| Pathname | The path after the host, like /demo | Kept; combined with origin. Trailing slash is trimmed except on the site root |
| Query string | The ?key=value part | Stripped before runtime compare — do not rely on UTM in a URL rule |
| Hash | The #section part | Stripped before runtime compare |
| Include | Allow this page | At least one include rule must match or targeting fails |
| Exclude | Block this page | If any exclude rule matches, targeting fails immediately |
| Match type | How to compare the pattern to the page | Exact, Contains, Starts with, Regex, and the other string operators (0–9) |
| Exact | The whole cleaned URL is the same | Enum 0 — https://example.com does not match https://example.com/demo |
| Contains | The pattern appears somewhere in the cleaned URL | Enum 2 — /demo matches a path that includes that text |
| Starts with | The cleaned URL begins with this text | Enum 4 — common for “entire marketing site” |
| Regex | A pattern language | Enum 8 — RegExp test against the cleaned string; mistakes fail closed |
| urlPattern | The text you type as the rule | Normalized the same way as the current page when it parses as a URL |
| isExclude | Whether this row is a block rule | Boolean or 0/1 in compact configs |
| Compact format | A short array instead of a named object | [matchType, urlPattern, isExclude] used by Smart Code / compact configs |
| Condition | A rule | URL data type uses match type URL match (20), which evaluates this whole pack |
Screenshot
Use this screenshot filename when you add a capture: url-rules.png in docs/assets/placeholders/. Do not embed an image in this file.
Two shapes you will see
1) Experiment page targeting (objects)
Historically and in API models, each rule looks like:
{ urlPattern, matchType, isExclude }
The UI splits these into include and exclude lists. You still need at least one include. Empty exclude is allowed (nothing is blocked extra).
2) Compact array-of-arrays (Smart Code / compact configs)
Each rule is a three-item array:
[matchType, urlPattern, isExclude]
Example:
[
[0, "https://croforge.com", false],
[0, "https://marqueesolution.com/", false],
[0, "https://croforge.com/contact", true]
]
Read that as: exact-include https://croforge.com, exact-include https://marqueesolution.com/, exact-exclude https://croforge.com/contact. isExclude may be boolean or 0/1.
Evaluation algorithm
Runtime (Smart Code) typically:
- Normalize the current page to
origin + pathname(trim trailing slash except root). Query string and hash are stripped. - For each rule, normalize the pattern the same way when it parses as a URL.
- Apply the rule’s match type against those cleaned strings.
- If any exclude rule matches → fail.
- If no include rule matches → fail.
- Else pass.
That is the same as includeMatch && !excludeMatch. Prefer patterns that already look like origin + pathname (no ?query, no #hash).
Include / exclude examples
Results below assume the visitor is on a cleaned URL whose pathname is /demo.
| Include | Exclude | Result on /demo |
|---|---|---|
Starts with https://example.com | Contains /blog | Pass |
Exact https://example.com/ | — | Fail (path is /demo, not the homepage) |
Contains /demo | Exact https://example.com/demo/old | Pass |
UI behavior
The URL rule row component manages include/exclude arrays, validation (at least one include), and serialization for forms. The same pack is used inside metric and segment conditions when the data type is URL (match type URL match = 20).
Experiment Pages also expose a validator: paste sample URLs and see whether they would be targeted. Use it before launch. See Pages and URL targeting.