Developer guide: 8. People analysis
Cohorts, actions, metrics, lifecycle, paths and other people analysis over the API.
8. People analysis
8.1 Cohorts
A cohort is a saved group of people. dynamic cohorts are defined by criteria and recalculated about every 15 minutes. static cohorts are a fixed list you fill.
Method and path | Scope | Purpose |
|---|---|---|
|
| List ( |
| read / write | PATCH |
|
| Queue a recalculation (dynamic) |
|
| Copy |
|
|
|
|
|
|
|
| Members: |
|
| Add to a static cohort |
|
| Add |
|
|
|
|
| Is this id in the cohort? POST |
|
|
|
COHORT_ID=$(lc -X POST "$P/cohorts" -d '{"name":"Pro buyers","kind":"dynamic","description":"pro plan, bought in 30 days",
"filters":{"type":"and","values":[
{"type":"performed","event":"purchase","window":{"days":30}},
{"type":"person_property","filters":{"and":[{"key":"plan","type":"person","op":"eq","value":"pro"}]}}]}}' | jq -r .id)
sleep 5; lc "$P/cohorts/$COHORT_ID" | jq '{status, member_count, last_computed_at}' # status: pending, then ready
lc "$P/cohorts/$COHORT_ID/members?limit=3" | jq '.data[] | {id, distinct_ids}'
lc -X POST "$P/cohorts/$COHORT_ID/members/check" -d '{"distinct_ids":["user_18","nobody"]}'
STATIC=$(lc -X POST "$P/cohorts" -d '{"name":"VIP list","kind":"static"}' | jq -r .id)
lc -X POST "$P/cohorts/$STATIC/members" -d '{"keys":["user_1","user_2","ghost@example.com"]}' | jq '{submitted, matched, unmatched, column}'The cohort object: id, name, description, kind, filters, version, status, last_error, last_computed_at, member_count, realtime, created_by, created_at, updated_at. status is pending or ready. Members and uploads answer {cohort, submitted, matched, unmatched, column}.
filters for a dynamic cohort is a tree whose root is {"type":"and"|"or","values":[...]}. Child type: performed / not_performed (event or action_id, window, performed also count: {"op": "gte|lte|eq|gt|lt", "n": n}, filters), sequence / not_sequence (steps: [{"event": ...}], window, within: {"amount", "unit": minute|hour|day}), person_property (filters: an and/or group of person tests), in_cohort / not_in_cohort (cohort_id), lifecycle (state: new|returning|dormant, window, event?), stopped / started (event, previous, recent), regular (event, times, period, periods, min_periods). A window is {"days": 7}, {"amount": 2, "unit": "day|week|month|year"} or {"from": "...", "to": "..."}. realtime: true also adds members as events arrive; it is only allowed for and/or trees of simple performed (an event at least once in the last N days) and person_property children. Use a cohort in queries as a filter with type: "cohort" or in compare_cohorts / compare_segments. Full reference: Cohorts and actions.
8.2 Predictive cohorts and computed traits
Predictive cohorts train a model on past behaviour and keep the top scorers as a cohort.
Method and path | Scope | Purpose |
|---|---|---|
|
| List; create (trains and scores at once) |
| read / write | Read; replace; delete |
|
| Retrain now |
lc -X POST "$P/predictive-cohorts" -d '{"name":"Likely buyers","goal":"purchase","features":["$pageview","added_to_cart","signed_up"],
"horizon_days":7,"lookback_days":30,"selection":{"top_k":500},"model_kind":"linear","retrain_every_hours":24}'Required: name, goal (event), features (1-20 event names), selection ({"top_k": 1-10000} or {"threshold": p} with 0 < p < 1). Optional: horizon_days 1-90 (7), lookback_days 1-180 (30), model_kind linear | interactions, property_features ([{event,key,value}], at most 20 features in all), target conversion | revenue (revenue needs value_property), retrain_every_hours 1-8760, retrain_from attempt | success, seed. Training needs enough data: 422 not enough data to train: need at least 50 people with 5 who reached the goal and 5 who did not. A trained cohort reports holdout AUC in metrics. See Realtime and predictive cohorts.
Computed traits write an aggregate of events onto person or group profiles.
Method and path | Scope | Purpose |
|---|---|---|
|
| List; create |
| read / write | Read; replace (full body); delete |
|
|
|
|
|
|
CT=$(lc -X POST "$P/computed-traits" -d '{"name":"Orders 30d","entity":"person","aggregate":"count","event":"purchase",
"window_days":30,"property":"orders_30d","enabled":true}' | jq -r .id)
lc -X POST "$P/computed-traits/$CT/run" -d '{"dry_run":true}' | jq '{entities, changed, written, dry_run}'entity is person or group (group needs group_type_index 0-4). aggregate is count, sum, last, most_frequent, first_seen or last_seen; sum, last and most_frequent need math_property. window_days 1-365 (30). filters is [{property, op, value}], all must hold. property is the profile property written (default trait_<slug of name>, never $lc_*). Response also has last_run_at, last_status, last_error, last_entities, last_written.
8.3 Actions
An action names a set of interactions you can use like an event in queries (source: {"type":"action","id": ...}).
Method and path | Scope | Purpose |
|---|---|---|
|
| List; create |
| read / write | PATCH |
| read / write | A reference screenshot |
ACTION_ID=$(lc -X POST "$P/actions" -d '{"name":"Viewed pricing","description":"pricing page views","steps":[
{"event":"$pageview","url":"/pricing","url_match":"contains"},
{"event":"$autocapture","selector":"a.pricing","text":"Pricing","text_match":"contains"}]}' | jq -r .id)
q '{"kind":"trends","date_range":{"from":"-30d","to":"now"},"series":[{"source":{"type":"action","id":"'$ACTION_ID'"}}]}'steps: 1-50 alternatives, the action matches when any step does, and all fields inside one step must match. A step may set event, selector (CSS subset tag#id.class[attr="v"]:nth-child(n), joined by space or >), tag_name, text with text_match (exact|contains), href with href_match, url with url_match (exact|contains|regex), screen_name with screen_name_match, and properties (an and/or filter group). With no event, it is $autocapture when an element field is set, $pageview when only url is set, $screen when only screen_name is set. Unknown step fields are 400. A taken name is 409. With webhook_endpoint_id the webhook is called when an ingested event matches.
8.4 Governed metrics, groups and trees
A metric is a named, reusable definition with an owner and an approval state (proposed, approved). Experiments, insights and metric trees refer to them.
Method and path | Scope | Purpose |
|---|---|---|
|
| List ( |
| as above (reads: | Read; replace ( |
|
| Run: `{date_from?, date_to?, interval?, refresh?: cache |
|
|
|
|
| Approve ( |
|
|
|
| project access | Re-read the source insight; detach from it |
|
| Warehouse model metrics |
|
|
|
|
|
|
|
| The north-star tree |
|
| Values, deltas and contribution per node for the period |
M=$(lc -X POST "$P/metrics" -d '{"name":"signup_conversion","display_name":"Signup to purchase","kind":"proportion","unit":"%","tags":["growth"],
"definition":{"event":{"source":{"type":"event","name":"purchase"}},"window_days":7}}' | jq -r .id)
M2=$(lc -X POST "$P/metrics" -d "{\"name\":\"daily_signups\",\"source_insight_id\":\"$INSIGHT_ID\"}" | jq -r .id) # kind "query" from an insight
lc -X POST "$P/metrics/$M2/approve" | jq '{status, certified}'
lc -X POST "$P/metric-groups" -d "{\"name\":\"Growth KPIs\",\"metric_ids\":[\"$M\",\"$M2\"]}"
lc -X POST "$P/metric-trees" -d "{\"name\":\"Conversion tree\",\"north_star\":true,\"nodes\":[
{\"id\":\"root\",\"label\":\"Purchase conversion\",\"metric_id\":\"$M\",\"parent_id\":null}]}"name must match ^[a-z][a-z0-9_]{0,62}$ for governed kinds (409 metric_name_taken; pass overwrite: true to replace a live metric of that name). kind and definition: proportion ({event:{source,filters?}, window_days}), mean ({value:{source, property}}), ratio (numerator, denominator), funnel, retention, quantile, threshold (experiment kinds), query (a query IR, from source_insight_id; mutually exclusive with definition), plus stub, markdown and LQL/warehouse_sql kinds. Omit both kind and definition for a stub. Other fields: description, display_name, unit, tags, owner_id, created_source (user|ai_generated), ai_model, confidence (0..1), reasoning. Behaviours seen live: run on an experiment-only kind (proportion, mean, ...) is 422 ... measured inside experiments and insights, not run on their own; run on a query metric answers {kind, results, compiled_query, url, status, ...}; a {"type":"metric","id":...} series source in /query works for event-based proportion and mean metrics; for a query metric it is 400 ... is a query metric, which cannot be a series source. To make a query metric send source_insight_id, with kind: "query" or without kind; any other kind, or an explicit definition, alongside it is 400. Tree nodes are {id, label, metric_id, parent_id, relation?, mean_of_ratios?}; relation is sum, product or driver (default); tree metrics must be proportion, mean, ratio, funnel or retention. north_star: true clears the flag on any other tree.
8.5 Usage metrics, health scores, engagement, adoption
Method and path | Scope | Purpose |
|---|---|---|
|
| Per-customer usage metrics |
| project access | `{entity: person |
|
| Saved health scores |
|
| Run (answers the |
|
| Product engagement score: |
|
| Feature adoption funnel |
|
| Time from signup to first value |
lc -X POST "$P/usage-metrics" -d '{"name":"Features used","source":{"kind":"events","matchers":[{"type":"event","name":"feature_used"}]},
"calc":"count","interval_days":30,"applies_to":"both","display":"sparkline"}'
lc -X POST "$P/usage-metrics/evaluate" -d '{"entity":"group","group_type_index":0,"keys":["acme","globex"]}'
HS=$(lc -X POST "$P/health-scores" -d '{"name":"Account health","config":{"signals":[{"event":"feature_used","weight":2,"target":5},{"event":"purchase","weight":1,"target":3}],
"window_days":30,"entity":{"groups":{"index":0}},"healthy_at":70,"at_risk_at":40}}' | jq -r .id)
lc -X POST "$P/health-scores/$HS/run" -d '{}' | jq '.rows[0:2]'
lc -X POST "$P/adoption" -d '{"feature":[{"kind":"event","name":"added_to_cart"}],"adopt_uses":2,"retain_days":7}'
lc -X POST "$P/adoption/time-to-value" -d '{"signup":{"kind":"event","name":"signed_up"},"value":{"kind":"event","name":"purchase"},"window_days":30}'Usage metric: source is {"kind":"events","matchers":[{type: event|action, name|id, filters?}]} (matchers OR-ed) or {"kind":"warehouse","table","timestamp_field","key_field"}; calc count | sum (with math_property); interval_days 7, 30 or 90 (30); applies_to person | group | both (default); display number | sparkline; format numeric | currency; group_type_index 0-4; filters a property group. Health score config is the health_score query without kind (6.3). Adoption stages: {discovered, used, adopted, retained, use_rate, adopt_rate, retain_rate}; feature and discovery are [{kind: event|action, name}], adopt_uses default 3, retain_days default 7, and from/to optional. Time to value: window_days default 30, max 90, answers {signups, converted, conversion_rate, p25_s, p50_s, p75_s, p90_s, buckets}. The engagement score is (adoption + stickiness + growth) / 3 over events you flag core with PATCH {p}/event-definitions/{name} {"is_core": true} (at most 100); with none flagged it answers all null and an empty core_events.
8.6 Customer journeys and customer analytics
A customer journey is a named funnel of steps with a conversion window, tracked per customer.
Method and path | Scope | Purpose |
|---|---|---|
|
| List; create |
| read / write | Read; replace; delete |
|
|
|
| read / write | Templates |
|
|
|
|
| `{step (0-based), scope: between |
| project access | One customer's progress: `?entity=person |
|
|
|
|
| Which events mean activity, signup, payment |
|
|
|
|
|
|
J=$(lc -X POST "$P/customer-journeys" -d '{"name":"Signup to purchase","window_days":14,"steps":[
{"label":"Signed up","source":{"type":"event","name":"signed_up"}},
{"label":"Cart","source":{"type":"event","name":"added_to_cart"},"optional":true},
{"label":"Purchased","source":{"type":"event","name":"purchase"}}]}' | jq -r .id)
lc -X POST "$P/customer-journeys/$J/run" -d '{"days":30}' | jq '.steps[] | {label, entities, conversion_from_previous}'
lc -X PUT "$P/customer-analytics/config" -d '{"mode":"b2c","events":{
"activity":{"source":{"type":"event","name":"$pageview"}},"signup":{"source":{"type":"event","name":"signed_up"}},
"payment":{"source":{"type":"event","name":"purchase"}}}}'Journey steps: [{label, source:{type: event|action, name|id}, filters?, optional?}], the first step required, window_days default 14, 409 for a taken name. Customer analytics events keys are activity, signup_pageview, signup, subscription, payment; mode is b2c (default) or b2b (needs group_type_index 0-4).
8.7 Accounts (groups), relationships and tasks
Groups are accounts (companies, workspaces). Capture them with $groupidentify events and $groups on events (part A).
Method and path | Scope | Purpose |
|---|---|---|
|
|
|
|
| Rename a group type |
|
| List groups of a type ( |
| read / write | One group; edit properties |
|
| Its events |
| read / write | Account team: POST |
|
| PATCH |
| read / write | Account tasks: POST `{title, notes?, due_on?, assignee_id?, status?: open |
|
| Tasks across accounts: `?status=&assignee=<user id |
|
|
|
lc -X POST "$P/groups/0/acme/tasks" -d '{"title":"Schedule QBR","notes":"renewal in Q1","due_on":"2026-12-01"}'
lc -X POST "$P/groups/0/acme/relationships" -d "{\"kind\":\"csm\",\"user_id\":\"$USER_ID\"}" # {"id":"..."}Dates (due_on, starts_on, ends_on) are YYYY-MM-DD; starts_on defaults to today (UTC). Relationship listings include the member's name and email, so treat them as personal data. The account_team alert channel (9.1) notifies the people in these relationships.
8.8 Product areas, friction, content analytics, app usage
Method and path | Scope | Purpose |
|---|---|---|
|
| Product areas |
|
|
|
|
| Rage and dead click signals: |
|
| Friction clusters by signal count: |
|
|
|
|
| Page content attributes: report `?attribute=topic |
|
| Set or clear page attributes |
| project access | Record that a user used a Lucida app area: `{feature, object_type?: dashboard |
url_patterns are exact $pathname values or * globs (/billing/*). frustration and friction need replays or autocapture signals, so they answer empty lists on a project with server events only. GET {p}/retention and PUT {p}/retention (settings:read / admin) are data retention, not retention analysis: {person_days, audit_days, export_days}. Retention analysis is the retention query kind (6.3).