Developer guide: 8. People analysis

Cohorts, actions, metrics, lifecycle, paths and other people analysis over the API.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide-people-analysis"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/ee8cddf8-31ed-4b01-be7b-827fa6751760/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: 8. People analysis" width="600" height="315"></a>

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

GET/POST {p}/cohorts

cohort:read / cohort:write

List (?q=&limit=&cursor=); create

GET/PATCH/DELETE {p}/cohorts/{id}

read / write

PATCH {name?, description?, filters?, realtime?}; 409 if an enabled flag targets the cohort and you change its filters

POST {p}/cohorts/{id}/recalculate

cohort:write

Queue a recalculation (dynamic)

POST {p}/cohorts/{id}/duplicate

cohort:write

Copy

POST {p}/cohorts/snapshot

cohort:write

{name, filters}: evaluate once now into a static cohort

POST {p}/cohorts/from-query

cohort:write

{name, query, description?}: a static cohort from an insight_actors or funnel_persons query, or a sql query with a person_id column, read from the result's columns the way /query does (first 10,000 persons)

GET {p}/cohorts/{id}/persons (alias .../members)

cohort:read

Members: ?limit=&cursor=, {data:[{id, properties, created_at, distinct_ids}], next_cursor}

POST {p}/cohorts/{id}/members

cohort:write

Add to a static cohort {keys:[distinct ids or emails, max 10,000]}

POST {p}/cohorts/{id}/persons, DELETE .../persons/{person_id}

cohort:write

Add {person_id} / remove one person (static only; 400 otherwise)

POST {p}/cohorts/{id}/upload

cohort:write

multipart/form-data, field file: a CSV (max 20 MB, 1M rows). A header person_id, distinct_id (or user_id, id) or email picks the column, in that order; without a header the first column is used

GET/POST {p}/cohorts/{id}/members/check

cohort:read

Is this id in the cohort? POST {distinct_ids:[1-1000]} returns {members:[{distinct_id, person_id}]}; person_id needs pii:read (omitted otherwise)

GET {p}/cohorts/{id}/size-history

cohort:read

{cohort_id, points}

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

GET/POST {p}/predictive-cohorts

cohort:read / cohort:write

List; create (trains and scores at once)

GET/PUT/DELETE {p}/predictive-cohorts/{id}

read / write

Read; replace; delete

POST {p}/predictive-cohorts/{id}/retrain

cohort:write

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

GET/POST {p}/computed-traits

person:read / person:write

List; create

GET/PUT/DELETE {p}/computed-traits/{id}

read / write

Read; replace (full body); delete

POST {p}/computed-traits/{id}/run

person:read

{dry_run?}: compute and (unless dry run) write

GET {p}/computed-traits/{id}/values

person:read

{data:[{entity_key, value, updated_at}], next_cursor}

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

GET/POST {p}/actions

action:read / action:write

List; create {name, steps, description?, webhook_endpoint_id?}

GET/PATCH/DELETE {p}/actions/{id}

read / write

PATCH {name?, description?, steps?, webhook_endpoint_id?, clear_webhook?}

GET/PUT/DELETE {p}/actions/{id}/screenshot

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

GET/POST {p}/metrics

data_catalog or data_catalog_approval to write; reads also accept insight:read

List (?q=&status=&created_source=&drifted=&source_insight_id=&limit=&cursor=); create

GET/PUT/DELETE {p}/metrics/{id}

as above (reads: insight:read, writes: data_catalog or data_catalog_approval)

Read; replace (name required); delete

POST {p}/metrics/{id}/run

insight:read, data_catalog or data_catalog_approval

Run: `{date_from?, date_to?, interval?, refresh?: cache

POST {p}/metrics/{id}/duplicate

data_catalog or data_catalog_approval

{name?} makes a proposed copy

POST {p}/metrics/{id}/approve

data_catalog_approval

Approve (409 metric_drifted if the source changed)

PUT {p}/metrics/{id}/certification

data_catalog_approval

{certified} approve or send back

POST {p}/metrics/{id}/refresh-from-insight, /unlink

project access

Re-read the source insight; detach from it

GET {p}/metrics/warehouse-models, POST .../sync

insight:read / insight:write

Warehouse model metrics

GET/POST {p}/metric-groups, GET/PUT/DELETE .../{id}

insight:read / insight:write

{name, metric_ids:[1-50, no repeats], description?}

GET/POST {p}/metric-trees, GET/PUT/DELETE .../{id}

insight:read / insight:write

{name, nodes, north_star?, description?}

GET {p}/metric-trees/north-star

insight:read

The north-star tree

GET {p}/metric-trees/{id}/evaluate

insight:read

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

GET/POST {p}/usage-metrics, GET/PUT/DELETE .../{id}

insight:read / insight:write

Per-customer usage metrics

POST {p}/usage-metrics/evaluate

project access

`{entity: person

GET/POST {p}/health-scores, GET/PUT/DELETE .../{id}

insight:read / insight:write

Saved health scores {name, config, description?}

POST {p}/health-scores/{id}/run

insight:read

Run (answers the health_score result shape)

GET {p}/engagement-score

insight:read

Product engagement score: ?from=&to=

POST {p}/adoption

insight:read

Feature adoption funnel

POST {p}/adoption/time-to-value

insight:read

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

GET/POST {p}/customer-journeys

insight:read / insight:write

List; create

GET/PUT/DELETE {p}/customer-journeys/{id}

read / write

Read; replace; delete

POST {p}/customer-journeys/from-funnel

insight:write

{insight_id, name?}: copy the steps of a saved funnel insight

GET/POST {p}/customer-journeys/templates

read / write

Templates

POST {p}/customer-journeys/{id}/run

insight:read

{days?: 30} returns {journey_id, days, steps:[{index, label, optional, entities, conversion_from_previous, conversion_from_start, dropped, at_position}]}

POST {p}/customer-journeys/{id}/paths

insight:read

`{step (0-based), scope: between

GET {p}/customer-journeys/{id}/progress

project access

One customer's progress: `?entity=person

POST {p}/customer-journeys/{id}/steps/promote

insight:write

{event, label?, optional?, position?} add a path node (an event name, or a page path starting with /) as a step

GET/PUT {p}/customer-analytics/config

insight:read / insight:write

Which events mean activity, signup, payment

GET {p}/customer-analytics/dashboard

insight:read

?days=&mode=&group_type_index= returns {days, mode, group_type_index, tiles}

GET {p}/customer-analytics/suggest-event

insight:read

?role=&ai=: candidate events for a role; ai=true needs a connected AI provider (409 otherwise)

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

GET {p}/group_types

person:read

{data:[{group_type, group_type_index}]}

PATCH {p}/group_types/{type_index}

admin

Rename a group type

GET {p}/groups?type_index=0

person:read

List groups of a type (type_index is required)

GET/PATCH {p}/groups/{type_index}/{key}

read / write

One group; edit properties

GET {p}/groups/{type_index}/{key}/events

person:read

Its events

GET/POST {p}/groups/{type_index}/{key}/relationships

read / write

Account team: POST {kind, user_id, starts_on?, ends_on?}; kind is csm, ae, am, se, sponsor or another lowercase role key

PATCH/DELETE {p}/account-relationships/{id}

person:write

PATCH {ends_on} (null makes it ongoing; 204)

GET/POST {p}/groups/{type_index}/{key}/tasks

read / write

Account tasks: POST `{title, notes?, due_on?, assignee_id?, status?: open

GET {p}/account-tasks

person:read

Tasks across accounts: `?status=&assignee=<user id

PATCH/DELETE {p}/account-tasks/{id}

person:write

{title?, notes?, due_on?, assignee_id?, status?}

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

GET/POST {p}/product-areas, GET/PUT/DELETE .../{id}

insight:read / insight:write

Product areas {name, description?, url_patterns?, events?, action_ids?}; 409 name taken

GET {p}/product-areas/{id}/report

insight:read

?from=&to=&weeks=: {active_users, area_users, adoption, area_sessions, stickiness, retention, frustration_signals, frustrated_sessions}

GET {p}/frustration

insight:read

Rage and dead click signals: ?from=&to= returns {by_element, by_page, trend}

GET {p}/friction/clusters

replay:read

Friction clusters by signal count: ?from=&to=&limit=

GET {p}/friction/impact

replay:read

?goal=<event>&revenue_property=&from=&to=&limit=: conversions and revenue at risk

GET/PUT {p}/content-analytics, GET {p}/content-analytics/report

insight:read / admin

Page content attributes: report `?attribute=topic

PUT/DELETE {p}/content-analytics/attributes

insight:write

Set or clear page attributes

POST {p}/app-usage

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).

Updated