Url Rules

Documents / Conditions

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

WordEveryday meaningMeaning in CROForge
URLThe full address of a pageThe value targeting compares after it is cleaned
Originhttps:// plus host (and port if any)Kept in the cleaned string, for example https://example.com
PathnameThe path after the host, like /demoKept; combined with origin. Trailing slash is trimmed except on the site root
Query stringThe ?key=value partStripped before runtime compare — do not rely on UTM in a URL rule
HashThe #section partStripped before runtime compare
IncludeAllow this pageAt least one include rule must match or targeting fails
ExcludeBlock this pageIf any exclude rule matches, targeting fails immediately
Match typeHow to compare the pattern to the pageExact, Contains, Starts with, Regex, and the other string operators (0–9)
ExactThe whole cleaned URL is the sameEnum 0 — https://example.com does not match https://example.com/demo
ContainsThe pattern appears somewhere in the cleaned URLEnum 2 — /demo matches a path that includes that text
Starts withThe cleaned URL begins with this textEnum 4 — common for “entire marketing site”
RegexA pattern languageEnum 8 — RegExp test against the cleaned string; mistakes fail closed
urlPatternThe text you type as the ruleNormalized the same way as the current page when it parses as a URL
isExcludeWhether this row is a block ruleBoolean or 0/1 in compact configs
Compact formatA short array instead of a named object[matchType, urlPattern, isExclude] used by Smart Code / compact configs
ConditionA ruleURL 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:

  1. Normalize the current page to origin + pathname (trim trailing slash except root). Query string and hash are stripped.
  2. For each rule, normalize the pattern the same way when it parses as a URL.
  3. Apply the rule’s match type against those cleaned strings.
  4. If any exclude rule matches → fail.
  5. If no include rule matches → fail.
  6. 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.

IncludeExcludeResult on /demo
Starts with https://example.comContains /blogPass
Exact https://example.com/Fail (path is /demo, not the homepage)
Contains /demoExact https://example.com/demo/oldPass

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.

Related reading