> ## Documentation Index
> Fetch the complete documentation index at: https://docs.logbrew.co/llms.txt
> Use this file to discover all available pages before exploring further.

# What is product analytics? Metrics and returning users

> Select a project and dates. Read activity, funnels, retention, and lifecycle changes. Check data coverage before you act on the results.

Product analytics shows how people use your app. LogBrew reads the product
actions that your app sends, including page views, screen views, and
interactions. Use [Product event capture](https://docs.logbrew.co/guides/product-events.md) to send
these events with user and session context.

Every result is for one project and one time range. A service name does not
select a project. Logs and issues are separate signals. Their presence does
not mean that analytics data exists for the same range.

## Choose the command for the question

| Question | Command |
| - | - |
| Where do users come from? | `logbrew analytics properties` |
| Where do users drop off, and how many convert? | `logbrew analytics funnel` |
| Which traffic source converts best? | `logbrew analytics funnel --breakdown tag.utm_source` |
| Do users come back? | `logbrew analytics retention` |
| What do users do before or after a page? | `logbrew analytics paths` |
| Which pages and events are most used? | `logbrew analytics overview` |

`logbrew read actions` lists product actions only. Page views are trace
spans, so that list never contains them. Count page views with the analytics
commands, and read the page views of one visit with `logbrew read trace`.

The browser SDK adds `tag.utm_source`, `tag.utm_medium`, `tag.utm_campaign`,
and `tag.referrer_domain` to every event of a visit. It reads them from the
landing URL and the referrer. You do not need to add code for attribution. A
direct visit has none of these tags.

## Events, users, and sessions

| Unit | Meaning |
| - | - |
| Event | One recorded action. One person can send many events. |
| Identified user | A stable, opaque, app-supplied subject ID with kind `user`. |
| Anonymous subject | A typed subject ID that is not a user. It is never counted as a user. |
| Session | An explicit app-supplied session ID. One person can have many sessions. |

For example, 200 actions in 20 sessions do not mean that 20 people used the
app. Event totals are exact for the selected window. Unique user, session,
and anonymous-subject counts are approximate.

Use opaque IDs. Do not use names, email addresses, or other personal data as
IDs. The CLI analytics commands return up to 5 example session or user IDs
behind each number, exactly as your app sent them.

## Read the change, sample, and examples

Every CLI analytics command except lifecycle gives a `detail` object with the
answer:

| Field | Meaning |
| - | - |
| `sample_size` | Sessions or users behind the headline result. |
| `previous_since`, `previous_until` | The period of equal length just before the selected one. |
| `groups[].units`, `groups[].previous_units` | One number now and in the previous period. |
| `groups[].change`, `groups[].change_rate` | The difference and the relative change. |
| `groups[].rate_change_p_value`, `groups[].rate_change_significant` | A two-proportion test of the rate change: its p-value, and whether it is below 0.05. Trust a change only when it is significant. |
| `groups[].rate`, `groups[].base_units` | The number as a share of its population. |
| `groups[].breakdown` | The property value of a group, such as one traffic source. |
| `groups[].examples` | Up to 5 sessions or users, each with up to 3 action IDs and 3 trace IDs. |

Read the events of one example session, and the page views of its trace:

```bash theme={null}
logbrew read actions --session "<session_id>" --project "<project_id>" --since 24h --json
logbrew read trace "<trace_id>" --project "<project_id>" --json
```

Use `--user "<user_id>"` instead of `--session` for an example user. A small
sample can change a lot from one period to the next. Give the sample size
with every rate.

## Open the dashboard overview

1. Open **Analytics** in the LogBrew dashboard.
2. Select one project.
3. Select **24 hours**, **7 days**, **14 days**, **30 days**, or **Custom**.
4. Read the activity chart, then **Top events** and **Top surfaces**.
5. Open **Coverage and limits** before you read user counts.

For **Custom**, select the first and last day, then select **Apply**. Both
days are part of the range. For example, April 12 through April 16 is five
days. The dashboard uses UTC dates. A custom range is at most 31 days and
cannot include future dates.

The dashboard also shows two user trends for the same project and dates.
**Do users come back?** shows retention. **How is the user base changing?**
shows lifecycle groups. Both trends use all classified activity of
identified users. You do not select an event for them.

## Read the project overview

```bash theme={null}
logbrew analytics overview --project "<project_id>" --since 7d --json
```

Add `--until <RFC3339>` for an exclusive end time. `--interval` accepts
`auto`, `1m`, `5m`, `15m`, `1h`, `6h`, or `1d`. `--top-limit` sets the rows in
each top list, from `1` to `20`. The default is `10`. Add `--service`,
`--release`, or `--environment` to filter by exact context. The API endpoint
is `GET /api/telemetry/analytics/overview`.

The overview contains activity totals, a time series, top actions, and
classified activity. This excerpt shows the totals and their coverage:

```json theme={null}
{
  "schema_version": 3,
  "analysis_level": "user_and_session",
  "summary": {
    "actions": 120,
    "active_identified_users": 18,
    "active_anonymous_subjects": 7,
    "sessions": 24
  },
  "coverage": {
    "identified_actions": 100,
    "anonymous_actions": 20,
    "subject_coverage": {
      "index_version": 1,
      "identified_user_events": 100,
      "anonymous_subject_events": 8,
      "legacy_unknown_kind_events": 4,
      "missing_subject_events": 6,
      "historical_unindexed_events": 2
    },
    "sessionized_actions": 90,
    "traced_actions": 60,
    "top_actions_truncated": true
  },
  "next_action": { "code": "build_product_funnel" }
}
```

The five `subject_coverage` counts add up to `summary.actions`. Only
`identified_user_events` counts toward users. `anonymous_actions` includes the
four other states. In this example, 8 anonymous-subject events come from
about 7 different anonymous subjects. Neither number is a user count. A
truncated top list does not show that lower-volume events are absent.

`analysis_level` is `no_data`, `event_only`, `user_level`, or
`user_and_session`. It shows which questions the data can answer. The level
is the highest level that either `summary` or `classified_activity` supports.
It does not mean that both groups have users or sessions.

### Keep the two activity groups separate

| Response fields | Events counted |
| - | - |
| `summary`, `coverage`, `series`, `top_actions` | Product action events, including actions without a supported classification. |
| `classified_activity` | Page views, screen views, and interactions. Page views are not actions. |

Classified screen views and interactions are also actions. Do not add
`summary.actions` to `classified_activity.summary.events`. Read the coverage
of the group that you use. The subject counts in
`classified_activity.coverage.subject_coverage` add up to
`classified_activity.summary.events`.

`summary.actions` can be `0` while classified page views supply user and
session counts. Check `classified_activity` before you conclude that there
is no product activity.

### Follow the next action

`next_action` has a `code`, a `target`, and a `reason`. It shows the most
important capture gap or the next analysis step:

| `next_action.code` | Meaning |
| - | - |
| `capture_product_activity` | No product events match the scope. |
| `classify_product_activity` | Events exist, but none is a page view, screen view, or interaction. |
| `identify_product_users` | No event has a subject with kind `user`. |
| `sessionize_product_activity` | No event has a session ID. |
| `capture_funnel_steps` | Fewer than two named classified events exist. |
| `build_product_funnel` | The data can support a funnel. |

Make a capture change in the app, then check a new event. Older events do not
show that the change works.

### Call the API directly

Send an account bearer. Send `response_version=4` to get the same response
that the CLI reads, with `detail`. If you omit `response_version`, the API
returns version `1`, which has no anonymous-subject counts or
`subject_coverage`.

```bash theme={null}
curl -sS -G "https://api.logbrew.co/api/telemetry/analytics/overview" \
  -H "Authorization: Bearer $LOGBREW_ACCOUNT_BEARER" \
  --data-urlencode "project_id=<project_id>" \
  --data-urlencode "since=7d" \
  --data-urlencode "response_version=4"
```

`since` is a positive duration, such as `24h`, `7d`, or `30d`, or an RFC3339
timestamp. `until` is an optional RFC3339 timestamp. The range includes
`since` and does not include `until`. If you omit `until`, the range ends at
the request time. A range cannot be longer than 31 days.

For April 12 through April 16, 2026, send `2026-04-12T00:00:00Z` as `since`
and `2026-04-17T00:00:00Z` as `until`.

A range longer than 31 days returns HTTP `422`:

```json theme={null}
{
  "error": "product analytics range must not exceed 31 days",
  "code": "validation_failed",
  "next": "use a shorter range or query consecutive bounded windows",
  "next_action": { "code": "fix_request", "target": "request" }
}
```

Read `code` and `next_action` in program logic. Show `error` and `next` to a
person. [API errors](https://docs.logbrew.co/reference/api-errors.md) lists the other error responses.

The `POST` analytics routes below take a JSON body with the same `project_id`,
`since`, `until`, `service_name`, `release`, and `environment` fields. Unknown
body fields are rejected.

## Measure a funnel

A funnel measures conversion through two to eight ordered steps:

```bash theme={null}
logbrew analytics funnel --project "<project_id>" --since 7d \
  --step page-view /pricing \
  --step interaction checkout_started \
  --step interaction checkout_completed \
  --json
```

Each later step must have a later timestamp than the step before it. One event
cannot complete two steps. The default unit is the session. Use
`--unit identified-user` to count users across sessions. Copy the event names
from the overview. A ratio of two unrelated totals is not a conversion rate.

The final step must occur inside the conversion window that starts at the
first step. Set it with `--conversion-window`, for example `30m` or `1h`. The
default is 24 hours, or the full range if the range is shorter. The window
cannot be longer than the range.

Add `--breakdown tag.utm_source` to split every step by traffic source. Each
session or user counts under the first value that it carried. Use
`tag.referrer_domain` for visits from other sites. The split shows the 10
values with the most entries. Sessions without the property are one group. All other values form one more group.

The API route is `POST /api/telemetry/analytics/funnel`. The
[ordered funnel response](https://docs.logbrew.co/reference/telemetry-response-shapes.md#ordered-funnel-response)
shows the request body and the response.

## Explore paths around one event

Paths show the most common sequences of named events after or before one
anchor event:

```bash theme={null}
logbrew analytics paths following --project "<project_id>" --since 24h \
  --anchor-kind page-view --anchor-event /pricing \
  --json
```

Use `preceding` instead of `following` for the events before the anchor.
`--depth` sets the number of events on that side, from `1` to `8`. The
default is `4`. `--path-limit` sets the number of paths, from `1` to `20`. The
default is `10`. Consecutive identical events count as one event. Add
`--keep-repeated` to keep each one.

Paths use session IDs. A following path starts at the first anchor in each
session. A preceding path ends at the last anchor. Paths do not count users
and do not show why an action failed. The API route is
`POST /api/telemetry/analytics/paths`.

## Read retention

Retention shows whether identified users return after a start event:

```bash theme={null}
logbrew analytics retention --project "<project_id>" --since 30d \
  --start-kind page-view --start-event /signup \
  --return-kind interaction --return-event report_opened \
  --json
```

`--interval` is `hour`, `day`, `week`, or `thirty-day`. `thirty-day` is 30
days, not a calendar month. `--interval-count` is from `1` to `31`. The
default is `10`. `--mode return-on` counts returns in each exact period.
`return-on-or-after` counts returns in or after each period.

A return must occur after the user's start event. Each user starts once, at
the first start event in the range. That event is not always the user's
first event ever. A user who returns more than once in one period counts
once for that period.

Read the retained count with the eligible count for each period. Users whose
period has not ended yet are not eligible. They are not counted as lost.
For example, 40 returned users of 100 eligible users is 40% retention. A
lower return rate does not show why people left.

### Request retention for all activity

The API route is `POST /api/telemetry/analytics/retention`. To measure
retention without event names, send `response_version` `2` and omit
`start_event` and `return_event`:

```bash theme={null}
curl -sS "https://api.logbrew.co/api/telemetry/analytics/retention" \
  -H "Authorization: Bearer $LOGBREW_ACCOUNT_BEARER" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "<project_id>",
    "since": "14d",
    "response_version": 2,
    "interval": "day",
    "interval_count": 10,
    "mode": "return_on",
    "cohort_mode": "first_in_range"
  }'
```

The response sets `query.activity_scope` to `all_classified_activity`. Any
later page view, screen view, or interaction counts as a return. To select
events, omit `response_version` and send both `start_event` and
`return_event` as `{ "kind": "page_view", "event_name": "/signup" }`.

The range divided by the interval, multiplied by `interval_count`, must be 500
or less. For example, 14 days with `day` and `10` periods is 140. If you omit
`interval`, the API uses `hour` for ranges up to 48 hours and `day` for longer
ranges.

## Read lifecycle

Lifecycle puts identified users who did one event into one group per period:

```bash theme={null}
logbrew analytics lifecycle --project "<project_id>" --since 30d \
  --event-kind interaction --event report_opened \
  --json
```

| Group | Meaning |
| - | - |
| New in observed history | Active now, with no earlier event in the history window. |
| Returning | Active now and in the previous period. |
| Resurrected | Active now after a gap. |
| Dormant | Active in the previous period but not now. |

New in observed history does not mean a first-time customer. Earlier activity
can be outside the history window, set with `--history-periods`. Do not add
period totals to count unique users across the range.

`--history-periods` is from `2` to `31` periods before `since`. The default is
`2`. The history cannot be longer than 62 days. The range can have at most 100
periods. Each period has `fully_observed`, which is `false` when the period
has not ended. Dormant means inactive in the current period, not lost
permanently.

The API route is `POST /api/telemetry/analytics/lifecycle`. To use all
classified activity instead of one event, send `response_version` `2` and
omit `event`:

```json theme={null}
{
  "project_id": "<project_id>",
  "since": "30d",
  "response_version": 2,
  "interval": "day",
  "history_period_count": 7
}
```

## Compare two periods

Request each period separately. Use the same project, duration, event names,
and filters. Compare activity, the event mix, and identity and session
coverage before you compare user counts. An incomplete period can show lower
activity than a complete one.

| Observation | Next check | Limit |
| - | - | - |
| One event increased | Check its sessions and coverage. | More events do not show more people. |
| A conversion rate changed | Use the same funnel steps and unit for both periods. | Do not compare different funnel definitions. |
| Returning users decreased | Check eligible users and complete periods. | A recent cohort can look worse than an older one. |
| Users stop at one step | Read the issues and logs for that step. | A shared time range does not show cause. |

When a result points to a failure, read the related issues and logs for the
same project and time. Open a trace only when an event has an exact trace
link. A shared time range does not show that an error caused a drop.

To repeat a comparison, record the project ID, both UTC ranges, the
interval, filters, unit, coverage, and truncation states. Do not record raw
user IDs.

For response fields and errors, read the
[Telemetry API](https://docs.logbrew.co/reference/telemetry-api.md) and
[API errors](https://docs.logbrew.co/reference/api-errors.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.