Conditions Overview
A condition is a rule. Everyday meaning: “only if this is true.” In CROForge, a condition compares a real value (a visitor attribute, an event property, or the current page URL) to an expected value using a match type (how to compare).
You will meet the same building blocks in three places: who can enter an experiment (segments), which events count as a metric, and which pages an experiment may run on.
Words used on this page
| Word | Everyday meaning | Meaning in CROForge |
|---|---|---|
| Condition | A rule that must be true | One comparison: data type + match type + value (or a pack of URL rules) |
| Match type | How to compare two things | The operator (Exact, Contains, Starts with, Regex, Between, URL match, and so on) |
| Exact | The whole thing is the same | String or URL equals the expected value |
| Contains | This text appears somewhere inside | Substring match |
| Starts with | It begins with this text | Prefix match — common for “whole site except…” |
| Regex | A pattern language for text | Regular expression test; a bad pattern fails closed (no match) |
| Include vs exclude | Allow vs block | URL targeting: at least one include must match, and no exclude may match |
| AND | Every item must be true | Segment conditions usually all pass; metric conditions all pass for that event |
| OR | Any item may be true | Inside a text condition’s list of strings, any one value can satisfy the match |
| Attribute | A fact about a visitor | What segment conditions compare (device, UTM, visitor type, and more) |
| Event property | A fact attached to something that happened | What metric conditions compare (click text, amount, target URL) |
| URL | The address of a page | What experiment Pages compare; also a data type that uses URL-rule packs |
| Origin | https:// plus the host (and port if any) | Part of the cleaned URL Smart Code compares |
| Pathname | The path after the host, like /pricing | Combined with origin after query and hash are stripped |
| Query string | The ?utm_source=google part of a URL | Stripped before runtime URL compare |
| Hash | The #section part of a URL | Stripped before runtime URL compare |
| Data type | What kind of value it is | Text, Number, Boolean, or URL — this decides which match types appear |
| Segment | A named group of visitors | A list of attribute conditions; attached as experiment Audience |
| Metric | A success number you want to move | An event plus optional property conditions |
Screenshot
Use this screenshot filename when you add a capture: conditions-builder.png in docs/assets/placeholders/. Do not embed an image in this file.
Where conditions appear
| Surface | What is compared | Everyday example |
|---|---|---|
| Segment conditions | Visitor attributes | “Device is desktop” AND “UTM source is google” |
| Metric conditions | Event properties | “Click text is Book Demo” or “Amount is between 100 and 200” |
| Experiment pages | Current page URL (include / exclude) | “Starts with https://example.com” AND not “Contains /blog” |
The shared condition UI lives under components/common/condition-rule/*. Experiment Pages use the same include/exclude idea with URL rules.
Building blocks
Every condition is assembled from the same three pieces:
- Data type — Text, Number, Boolean, or URL. This is the kind of value, and it decides which operators the UI offers.
- Match type — the operator allowed for that type (Exact, Contains, Greater than, URL match, and so on).
- Value — a string list, a number or range, a boolean, or a URL rule array.
Text conditions often store a JSON array of strings and match if any item matches (OR within the list). Segment-level logic is still AND across conditions.
Evaluation mindset
- Segment: usually all conditions must pass (AND). An empty “All traffic” style segment matches everyone.
- Metric: all metric conditions must pass for that event before the metric counts.
- URL targeting: include must match and exclude must not. In other words
includeMatch && !excludeMatch.
Runtime URL compares typically use origin + pathname, with trailing slash normalized and query string / hash stripped. Write patterns that match that cleaned form. Full operators are in Match types. URL packs are in URL rules.