Guides
Targeting and audiences
Conditions, operators, built-in attributes and reusable audiences.
Targeting decides who a rule or an experiment applies to. You build it from conditions on the user's attributes; an audience is a set of conditions saved under a name so it can be reused in many flags and experiments.
Conditions#
A condition compares one attribute with a value:
{ "attribute": "country", "op": "in", "value": ["TR", "DE"] }Conditions combine into a tree with all (and), any (or) and not, and can refer to saved audiences and locations:
{
"all": [
{ "attribute": "country", "op": "eq", "value": "TR" },
{ "attribute": "device", "op": "eq", "value": "mobile" },
{ "location": "product_pages" },
{ "not": { "segment": "beta_testers" } }
]
}In the dashboard, the condition editor shows rows joined by and (or or at the top level), with proper pickers for countries, languages, devices and versions. Anything richer opens as JSON.
Operators#
| Operator | True when | Value |
|---|---|---|
eq | the attribute equals the value | one value |
neq | the attribute is set and differs from the value | one value |
in | the attribute is one of the values | a list |
nin | the attribute is set and none of the values | a list |
contains, startsWith, endsWith | text comparison | text |
matches | a JavaScript regular expression matches the text | a pattern |
gt, gte, lt, lte | numeric comparison (both sides must be numbers) | a number |
semverEq, semverGt, semverGte, semverLt, semverLte | version comparison: 2.10.0 is above 2.9.1 | a version |
exists | the attribute is set (not missing, not null) | none |
Add "ignoreCase": true to compare text case-insensitively (eq, neq, in, nin, contains, startsWith, endsWith, matches).
Exact semantics#
- Type-strict.
"10"never equals10. Send numbers as numbers if you compare them withgt/lt. - A missing attribute makes every operator false, including
neqandnin, exceptexists. To target users who don't have an attribute, use{ "not": { "attribute": "plan", "op": "exists" } }. all: []is true (everyone);any: []is false (no one).- An unknown audience, an unknown location and an unknown operator are false.
- Regular expressions are checked for catastrophic backtracking when saved and again in the SDK, and text longer than 1,024 characters never matches a regex, so a pattern can't freeze a visitor's browser.
Built-in attributes#
These keys are understood everywhere: SDKs, datafiles and saved audiences use them, and the dashboard offers proper pickers for them. The website snippet collects most of them by itself; anything else you pass yourself.
| Key | Meaning | Collected by |
|---|---|---|
country | From the visitor's IP address (ISO code, e.g. TR). | Website |
region | From the IP address (e.g. 34 for Istanbul, CA for California). | Website |
city | From the IP address. Less precise than country. | Website |
device | Detected from the browser.Values: desktop, mobile, tablet | Website |
os | Detected by the website snippet. In apps, pass Platform.OS yourself.Values: ios, android, windows, macos, linux, chromeos, other | Website |
browser | Detected from the browser.Values: chrome, safari, firefox, edge, samsung, opera, other | Website |
platform | Website or native app. The snippet sets web; apps pass ios or android.Values: web, ios, android | Website |
visitor | New during their first session on the site, returning afterwards.Values: new, returning | Website |
language | Browser language (e.g. tr, en). In apps, pass the device language yourself. | Website |
utm_source | utm_source of the landing URL, kept for the session. | Website |
utm_medium | utm_medium of the landing URL, kept for the session. | Website |
utm_campaign | utm_campaign of the landing URL, kept for the session. | Website |
referrer | Domain the visitor came from (e.g. google.com). Empty for direct visits. | Website |
path | Current page path, e.g. /checkout. | Website |
url | Current page address without the query string. | Website |
app_version | Pass your app's version (e.g. 2.4.0) as an attribute. | you |
- Country, region and city come from the CDN's geo headers (Cloudflare, Vercel or CloudFront) via the snippet's
/georequest; the SDK receives the place names, never the IP address. urlnever includes the query string or the hash. Locations match the full address, but on the device only (see Locations).- UTM values are the first touch of the session, so they stay the same while the visitor browses.
Your own attributes#
Pass anything else you know about the user: plan, company size, signup date, feature usage.
// Website snippet
liftcanary.setAttributes({ plan: "pro", seats: 12 });
liftcanary.identify("user_8812", { plan: "pro" }); // after login
// SDKs
const user = client.createUser({ id: "user_8812", attributes: { plan: "pro", seats: 12, app_version: "2.4.0" } });Audiences#
Audiences (Project → Audiences) are saved condition sets with a key, a name and a plain-language summary. The builder has a searchable attribute picker, country and language pickers that understand names like “Turkey”, “UK” or “USA”, all/any matching and Test a visitor, which runs the SDK's own evaluator against attributes you type.
- Use one in a rule or an experiment with
{ "segment": "key" }(the API calls audiences segments). - Audiences can include other audiences; cycles are rejected.
- An audience that is in use can't be deleted; the error lists where it's used.
- Editing an audience updates every flag and experiment that uses it, in the next datafile.