Developer guide: 14. Web analytics, live view and Replay Vision

Web analytics reports, the live view and Replay Vision over the API.

Embed
Preview of the card
<a href="https://lucidace.com/help/developer-guide-web-analytics"><img src="https://lucidace.com/help/_api/public/orgs/af34862a-c837-4478-8335-0505efe40459/spaces/2f4b888b-c4e6-488b-81bd-6e838fb12d2e/pages/28f263b8-3920-4267-ba96-b3a8fef71ae6/social-card.svg?v=3e7ae33eec8b" alt="Developer guide: 14. Web analytics, live view and Replay Vision" width="600" height="315"></a>

14. Web analytics, live view and Replay Vision

Web analytics is the traffic view: visitors, sessions, pages, referrers, channels, goals, attribution and revenue. It is computed from $pageview events and the properties below. All routes are GET {p}/web/... with insight:read unless stated; writes need insight:write.

What the events must carry, or reports stay empty:

  • $pageview with $host, $pathname (or $current_url), $referrer, and $session_id to group pageviews into one session. UTM keys: $utm_source, $utm_medium, $utm_campaign, $utm_term, $utm_content. The SDKs set all of these.

  • A browser User-Agent. Events sent by plain curl carry $bot_name: curl and are classified as bot traffic, which web reports exclude. When you test with curl, add -A "Mozilla/5.0 ... Chrome/130.0.0.0 Safari/537.36". GET {p}/live/bots shows what was classified as a bot.

  • Reports lag capture by seconds.

UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'
curl -sS -A "$UA" -X POST "$LUCIDA_CAPTURE/v1/batch" -H "Content-Type: application/json" -d '{"api_key":"'"$PK"'","batch":[{
  "uuid":"'"$(uuidgen | tr A-Z a-z)"'","event":"$pageview","distinct_id":"vis_1","properties":{
  "$current_url":"https://acme.test/pricing","$host":"acme.test","$pathname":"/pricing",
  "$referrer":"https://www.google.com/","$session_id":"'"$(uuidgen | tr A-Z a-z)"'","$utm_medium":"email"}}]}'

14.1 Overview, breakdown, realtime

lc "$LUCIDA_API/v1/projects/$PROJECT_ID/web/overview?from=2026-11-01T00:00:00Z&to=2026-11-10T00:00:00Z" | jq '{current,delta}'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/web/breakdown?dimension=channel&limit=10" | jq '.[] | {key,visitors,sessions}'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/web/realtime"      # {visitors, pageviews, by_country:[{key,visitors}]}  last 30 minutes

Route

Query

Returns

web/overview

from, to, compare (default true), compare_from + compare_to, host, properties, dims

{current, previous, delta}. current has visitors, sessions, pageviews, bounce_rate, avg_session_duration_s, views_per_session, engaged_sessions, engagement_rate, avg_events_per_session, avg_engagement_time_s. previous and delta are null with compare=false

web/breakdown

dimension (required), from, to, limit (default 100, max 1000), host, properties, dims

array of {key, visitors, sessions, pageviews, bounce_rate, avg_session_duration_s, scroll_depth}, most visitors first. key is "" when the value is not set. scroll_depth is for page only, bounce_rate is null for page

web/realtime

none

visitors and pageviews in the last 30 minutes

Default range is the last 30 days. from and to must be RFC 3339. host keeps one hostname. properties is a property-group JSON (only sessions with a matching event). dims is JSON {"channel":"Email","country":"DE"} for click-to-filter (at most 8).

Exact dimension values (singular; pages is 400 and the answer lists these):

page, entry_page, exit_page, referrer, channel, utm_source, utm_medium, utm_campaign, utm_term, utm_content, country, region, city, device, browser, os, host, language, resolution, browser_version, os_version, device_brand, device_model, visitor, visit_number, hour, weekday, timezone.

Channel values are labels such as Organic Search, Email, Organic Social, Direct, Referral, Paid Search, Paid AI/AI Referral. Override them with channel rules (14.5).

14.2 Goals

A goal turns a pageview or event into a conversion. Goals feed the overview chart and attribution (goal_id).

lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/web/goals" -d '{"name":"Reached signup","kind":"pageview","target":"/signup"}'
lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/web/goals" -d '{"name":"Purchase","kind":"event","target":"purchase","value_property":"amount"}'
lc "$LUCIDA_API/v1/projects/$PROJECT_ID/web/goals/report" | jq '.[] | {name:.goal.name,conversions,converters,conversion_rate}'

Route

Purpose

POST web/goals

{name, kind, target, value?, value_property?, timestamp_field?, distinct_id_field?}. kind is event, pageview, action or warehouse (else 400 kind must be event, pageview, action or warehouse). target is the event name, an exact $pathname, an action id or a warehouse table. value (0 to 1e9) and value_property are exclusive and not for pageview; warehouse goals need timestamp_field

GET web/goals

limit, cursor. Goal: {id, name, kind, event, pathname, value, value_property, source, created_at}

DELETE web/goals/{id}

remove

GET web/goals/report

from, to. [{goal, conversions, converters, visitors, conversion_rate, value}]

GET web/goals/series

daily points per goal

GET web/goals/candidates

suggested goals by UTM coverage

14.3 Attribution, spend, revenue

Route

Notes

GET web/attribution

exactly one of conversion_event or goal_id. Also from, to, lookback_days (default 30, max 365), dimension (channel or campaign), models (comma list of first_touch, last_touch, last_non_direct, linear, time_decay, position_based, data_driven), half_life_days (7), revenue_property. Returns models[].rows[] with credited conversions and revenue

GET web/attribution/paths

touchpoint sequences; adds model, limit, collapse_repeats

GET web/attribution/sessions

how recent sessions were classified (session_id, limit)

GET web/ad-spend/report, GET web/ad-spend/daily

spend joined to sessions: pass exactly one of conversion_event and goal_id (400 pass exactly one of conversion_event and goal_id)

POST web/ad-spend/import

body text/csv: header with date (YYYY-MM-DD) and spend; optional channel, campaign, campaign_id, ad_group, currency, impressions, clicks, conversions, conversion_value. Re-importing a day replaces it

GET web/budget/curves, POST web/budget/scenario

response curves; scenario body {days?, budgets:{key:amount}, total_budget?, optimize?, bounds:{key:{min,max}}} (insight:read)

GET web/marketing/diagnose

campaigns without spend, spend without sessions, unmapped paid sources

GET web/identity-fragmentation

one device seen as several persons

GET web/revenue, web/revenue/breakdown, web/revenue/mrr (interval month, week, day), web/revenue/deferred, web/revenue/lifetime, web/revenue/customers

revenue from $purchase / subscription events

GET, PUT web/revenue/config

event and property names (defaults $purchase, $revenue, $currency, $mrr, base currency USD)

GET, PUT web/revenue/rates; GET, PUT, DELETE web/revenue/rates/history; PUT, DELETE web/revenue/customers/{customer_id}

FX rates ({rates:[{currency,rate}]}), rate history, map a billing customer to a person ({person_id}); POST web/revenue/lifetime/refresh recomputes

14.4 Content, audience and other reports

All take from, to unless noted; most take limit.

Route

What it shows

web/content

content blocks; web/directory (depth) folder tree with rollups; web/articles article read-through; web/media video and audio engagement; web/outbound outbound clicks by host and by source page

web/time-on-page (host), web/search-exits, web/search-console (dimension, source)

time on page, exits after site search, Search Console and Bing data

web/active-hours (metric)

weekday by hour grid

web/breakdown/custom?dimension=<name>

pageviews grouped by a custom dimension

web/ai-traffic, web/ai-citations (dimension, source, conversion_event), web/ai-citations/topics (k), web/ai-visibility

AI crawlers, AI-search referrals, citations, share of voice

web/http-logs

status classes and 404/5xx paths from $http_log events or imported logs

web/digest?days= , web/narrative?days=

summary object; narrative text (needs a configured AI provider; without one it answers 503 problem+json, no AI provider is configured on this server)

GET /v1/orgs/{org_id}/web/rollup

one view over several projects of an org (session only; projects, from, to)

GET web/precompute, POST web/precompute/refresh

status and manual refresh of daily rollup tiles

14.5 Settings and configuration

lc -X PUT "$LUCIDA_API/v1/projects/$PROJECT_ID/web/settings" -d '{"bounce_threshold_s":10,"referrer_exclusions":["checkout.acme.com"]}'

PUT web/settings (insight:write) accepts: bounce_threshold_s (0 to 3600), bounce_ignores_interactions, referrer_exclusions[] (own domains shown as direct), host_allowlist[] (only these hosts are reported), campaign_match, utm_campaign_map, utm_source_allowlist, precompute, marketing_cards, marketing_onboarded, spend_tables[]. Unknown fields are rejected; the answer is the stored object.

Route

Body and purpose

GET, PUT web/channel-rules; DELETE web/channel-rules

{rules:[{channel, medium?, source?, campaign?, kind[]?, click_id[]?, utm?, has_medium?}]}; kind values search, social, ai, email, video, other, none. Replaces the default channel classification; DELETE restores it

GET, POST web/dimensions; DELETE web/dimensions/{id}

custom dimension {name, kind:"property"|"content_group", property?, rules:[{group, pattern}]}; * matches any run, e.g. /blog/*. Read with breakdown/custom

GET, POST web/shield-rules; DELETE web/shield-rules/{id}

drop events at the gateway before counting: {kind:"country"|"path"|"hostname", value, note?} (settings:write). Not retroactive

GET, POST web/short-links; DELETE web/short-links/{id}

{target_url, code? (3 to 64 of A-Za-z0-9_-), title?}; the gateway redirects /l/{code} and counts clicks

GET, POST web/shares; DELETE web/shares/{share_id}

public web dashboard link (body as in 13.5). Public: GET /v1/public/web/{token}?days=&filters=, embed /v1/embed/web/{token}

POST web/log-import?site=&dry_run=

body text/plain access-log lines (common, combined or JSON lines; 100 000 lines, 20 MiB); settings:write

GET, POST {p}/traffic-exclusions; PATCH, DELETE .../{id}; POST .../{id}/restore; POST .../preview

hide internal traffic from reports: {kind, value, key?, note?} with kind ip_cidr, hostname, path, distinct_id, event_property, person_property (key required for the last two). PATCH {enabled}. GET ?trash=true lists deleted rules. Preview takes {rules[], days}

14.6 Live view

Route

Purpose

GET {p}/live/visitors

{count, data:[{session_id, distinct_id, url, country, device, first_seen_ms, last_seen_ms, events}]}

GET {p}/live/visitors/stream

server-sent events of the same

GET {p}/events/live

server-sent event stream of incoming events; keep the connection open, do not use it in a request/response script

GET {p}/live/bots

bot requests per minute and by crawler name, category, share

14.7 Replay Vision

Vision asks one saved question of session transcripts (text, never video) using an LLM, and records an answer per replay. Use it to find "which sessions show confusion about pricing" without watching them. Scans cost money against the project's AI budget; use estimate first, and a monthly_cap_usd.

Scanner kind is monitor (yes or no verdict), classifier (pick categories), scorer (a number) or summarizer. model is claude-haiku-5-5 (about 0.002 USD per observation) or claude-opus-5-5 (about 0.08).

lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/vision/estimate" -d '{"filters":{"url_visited":"/pricing"},"coverage":"all","sample_rate":0.1,"model":"claude-haiku-5-5"}'
# {"matching_7d":1,"eligible_7d":0,"projected_monthly_observations":0.0,"per_observation_usd":0.002,"projected_monthly_usd":0.0,"capped":false}

lc -X POST "$LUCIDA_API/v1/projects/$PROJECT_ID/vision/scanners" -d '{
  "name":"Pricing confusion","kind":"monitor","prompt":"Did the visitor seem confused about the plan prices?",
  "filters":{"url_visited":"/pricing"},"coverage":"all","sample_rate":0.1,
  "model":"claude-haiku-5-5","monthly_cap_usd":5,"enabled":false}' | jq '{id,version}'

Scanner body: name, kind, prompt (1 to 4000 characters) required; description, tags[], config, filters (a replays/search body without date_range, limit, cursor, order_by, direction, hide_viewed, collection), coverage (high, medium, all, default all), sample_rate (0.001 to 1), model, monthly_cap_usd, monthly_max_observations, enabled (default true). config by kind: classifier {categories[] (max 30, 1 to 40 chars), multi, freeform} and needs categories or freeform:true; scorer {min, max, label} with min < max; summarizer {length:"short"|"medium"|"long", context}; any kind learned_rules[] (max 10).

Route

Scope

Purpose

GET, POST vision/scanners; GET, PUT, DELETE vision/scanners/{id}

read / write

scanners. POST vision/scanners/{id}/duplicate copies one

POST vision/estimate

read

monthly volume and cost estimate

POST vision/scanners/{id}/scan

write

{session_ids:[1..50 uuids]}: scan now, bypassing filters, sampling and coverage. One runs inline, more are queued

POST vision/scan-requests, GET vision/scan-requests/{id}

write / read

{scanner_id, session_id, idempotency_key?, wait_for_session_end?} for one scan, also by Idempotency-Key header

POST, DELETE vision/scanners/{id}/backfill; GET .../backfills; POST vision/backfills/{id}/{action}

write

backfill past recordings {hours (3 to 8760), max (1 to 500), dry_run}

GET vision/observations

read

filters scanner_id, session_id, state (pending, running, succeeded, failed, ineligible), triggered_by (schedule, on_demand, retry, backfill), verdict, tag, score_min, score_max, days (1 to 90), order=notability

GET vision/observations/{id}, .../similar; POST .../retry; PUT, DELETE .../rating

read / write

one observation; rate {up:true|false, note}

GET vision/observations/search?q=

read

lexical search of answers (q 2 to 500 chars, scanner_id)

GET vision/watch

read

what to watch: observations ranked by notability (scanner_id, verdict, tag, days)

GET vision/scanners/{id}/status, /impact, /variants (experiment_key, days)

read

health, how answers relate to duration and frustration, answers per experiment variant

POST vision/scanners/{id}/cohort

cohort:write + read

{name, answer?, days?} saves the people behind an answer as a static cohort

POST vision/scanners/{id}/rules/suggest

write

proposes rules from ratings; saves nothing

GET vision/usage

read

this month's spend, daily series, per scanner, projection

GET, POST vision/alerts; GET, PUT, DELETE vision/alerts/{id}; GET .../history; POST .../reset

read / write

{scanner_id, name, kind:"match"|"threshold", verdict?, tag?, score_min?, score_max?, metric (default count), op (default gte), value, window_hours (24, 72, 168, 336 or 720), cooldown_minutes, channels, enabled, required_breaches, of_checks, quiet_start, quiet_end, quiet_tz, auto_disable_after}


Updated