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

# Widget analytics

> How many visitors see, open and chat with a widget, per widget and per experiment variant.

Every published widget records a small set of events from your visitors' browsers: page views, opens, suggested-question clicks, conversations and cart adds from chat. A widget's **Analytics** page counts them, and an [experiment](/web-widgets/experiments)'s results show the same numbers per variant.

Every number is a plain count of what visitors did, so you can check it against your own view. Rates are always shown with the counts behind them (for example 412 / 5,210).

## Where to find it

* **A widget's Analytics page.** Open the widget and switch from **Builder** to **Analytics** at the top, or click the chart icon in the widgets list. Pick the last 7, 30 or 90 days and filter by device, new or returning visitors, UTM source, UTM campaign and landing page. The source, campaign and landing page lists offer the 50 most common values in the range, with their visit counts. The daily series uses your browser's time zone.
* **An experiment's results.** While an experiment runs or after it ends, its page shows the same metrics with one column per variant, over the time it ran (up to the last 90 days of it). An experiment that covers several widgets can show one of them at a time. Experiments that ran before analytics was collected show their conversation outcomes instead.

Results refresh every few minutes: they include activity up to the time shown beside **Refresh** (the last 5-minute mark), and **Refresh** reads them again. The page's address keeps the range and filters, so a link opens exactly what you see.

New or returning is decided once per visitor, by their first visit in the range: new if the widget had never seen them before it, returning if it had. All of their visits in the range count under that choice, so new and returning visitors add up to the total.

## Metrics

### Headline

| Metric | What it counts |
| - | - |
| Visitors | Distinct visitors who loaded the widget. On an experiment page, distinct visitors assigned that variant. |
| Sessions, page views | Visits (30 minutes without activity ends one) and the pages viewed in them, in-page navigations included. Volume, not rates. |
| Open rate | Visitors who opened the widget, any way, of all visitors; also per session. Shown with the share who opened it themselves. |
| Chat rate | Visitors who sent a message or clicked a quick action, of all visitors; also per session. |
| Funnel | Visitors → opened → chatted. |

<Note>
  Visitors are not comparable to your site analytics. The visitor id is kept per site address, so `www.` and `shop.` count as two visitors (who can see different experiment variants); Safari clears it after 7 days without a visit; visitors who block the widget, haven't consented or use browser automation aren't counted. Other bots are, as in any script-based analytics.
</Note>

### Panels

| Panel | What it counts | Shown |
| - | - | - |
| How visitors open | Opens by trigger, with the widget's own opens (`default_open`, and `link_carryover` when it reopens on the page an agent link led to) apart; visitors who opened it but never chatted; median pages viewed before opening; time from the launcher appearing to the open (median and 90th percentile), on that page and since it first appeared in the session, for opens the visitor chose. | Always |
| Suggested questions and teaser | Visitors who saw them, of all visitors; visitors who clicked, of those who saw them; visitors who dismissed them. Per question (named questions group under their name, and reworded text gets its own row) and per page rule. | When any were shown |
| Quick actions | Clicks per button, of conversations. | When any were clicked |
| Conversation | Time to first reply as the visitor saw it (median and 90th percentile); messages per conversation; conversations the visitor left while waiting for a reply; handoffs requested, completed and failed, of conversations; median handoff wait; how conversations ended. | Always |
| Forms | Shown, submitted and abandoned, by kind of form. | When any form was shown |
| Link clicks | Visitors who clicked a link the agent sent, of all visitors, and the ten most clicked. Counted at the click, before the open-link confirmation, so clicks are not arrivals. | When any were clicked |
| List value added from chat | Visitors who added to the cart from the chat; items; list value per currency; added by the agent vs from a product card. | When anything was added |
| Guardrails | Widget load time; visitors who opened but never chatted; dismissed suggestions; time to first reply. Watch these; don't pick a winner on them. | Always |

<Note>
  List value added from chat is an estimate. It uses the product's list price when it was added, before discounts, shipping and tax. Items removed later still count, items added outside the chat don't, and it doesn't mean an order was placed. It is shown per currency, with no conversion.
</Note>

### Counting rules

* A visitor is counted once for anything they did at least once in the range. Rates are over every visitor in the range (or assigned to the variant), whether or not they opened the widget.
* A conversation counts once the visitor sends a message or clicks a quick action: opening the widget starts one by itself. A resumed chat is part of the conversation it resumes.
* Experiments compare variants per visitor, the unit that is assigned. There are no significance tests; the experiment page warns when the variants' visitor counts are further from their weights than chance allows (chi-square, p \< 0.001), which means assignment is broken.

## What Anyreach receives

The embed loader sends these events, in batches, to `POST /core/public/web-widgets/{id}/events`:

| Group | Events | Fields beyond the envelope |
| - | - | - |
| Sessions | `page_viewed`, `exposure`, `widget_loaded` | Counted on the visit, never stored one by one: page views, the visitor's experiment variant, the first load time. |
| Widget | `widget_opened`, `proactive_message_shown`, `proactive_message_clicked`, `proactive_message_dismissed`, `quick_action_clicked` | Trigger, pages before opening, the two shown-to-open times; kind, question key, the question as configured (not as shown), page rule; action id and label. |
| Conversation | `message_sent`, `first_agent_response`, `conversation_ended`, `conversation_abandoned`, `form_shown`, `form_submitted`, `form_abandoned`, `handoff_requested`, `handoff_completed`, `handoff_unavailable` | Channel; reply time; end reason, message count, duration; who spoke last; form kind; handoff provider and wait. |
| Conversion | `link_clicked`, `cart_item_added` | The link's origin and path; the cart source, currency, and each item's id, quantity and price. |

The envelope sent with each is the visitor, session, widget, conversation and experiment ids, the page path, device type, UTM source, medium and campaign, and whether the visitor is returning.

Never sent: message text, the question text a visitor saw (it can carry values read from your page), form and feedback answers, `identify` traits and user ids, your `track` goals, full URLs, query strings, page titles, the page's referrer (where the visitor came from), and the journey events (`session_started`, `page_left`, `session_ended`). Page paths are stored with identifiers masked: a path segment that is all digits, a UUID, contains `@`, or is a long token with digits becomes `*` (`/account/orders/1234` → `/account/orders/*`); readable slugs such as `/products/ooni-koda-16` stay.

Anyreach drops a batch without telling the browser when the widget is unpublished or not collecting, the page's origin is not in the widget's [allowed domains](/web-widgets/allowed-domains-and-security), or the sender looks like a crawler. An event stamped with an experiment is dropped unless that experiment runs on the widget (or stopped less than an hour ago) and assigns that visitor that variant.

Each batch carries your site's origin (never the path) in its `Origin` and `Referer` headers, whatever referrer policy your page sets. Under a `no-referrer` or `same-origin` policy some browsers would otherwise send `Origin: null`, and the allowed-domains check would drop every event from that page.

## Turning it off

* **Collect analytics**, on the widget's General tab, turns it off for every visitor of that widget: nothing is sent, and your own page still receives the widget's events. It isn't part of the widget's settings that presets and experiment variants change. An experiment can't start on a widget that is unpublished or not collecting, and the switch can't be turned off while an experiment on the widget is running or paused.
* **`config({ analytics: false })`** on your page stops it for that visitor, for example until your consent banner is answered. Switching it back on reports the current page once; nothing from while it was off is ever sent.
* **`config({ pageEvents: false })`** stops Anyreach counting page views, and your page's journey events, while widget and conversation events still count.

Collection is on by default.

## Stored data and deletion

Nothing expires automatically yet. A widget's analytics are deleted with the widget. To delete one visitor's analytics across your organization, for a data-subject request, call `DELETE /core/widget-analytics/visitors/{anonymous_id}` with the `web_widgets:manage` scope; the visitor's `anonymous_id` is what `window.anyreach.getContext()` returns in their browser.

## API

| Method | Path | What it returns |
| - | - | - |
| `GET` | `/core/widget-analytics/widgets/{id}` | One widget's counts over the last `days` (1 to 90, default 30), in `timezone`, with optional `device_type`, `is_returning`, `traffic_source` (UTM source), `traffic_campaign` (UTM campaign) and `landing_path` filters. They aren't named `utm_*` because tracking-parameter filters strip those names from requests. `filter_options` lists the values the last three can take in the range, keyed `utm_source`, `utm_campaign` and `landing_path`. |
| `GET` | `/core/widget-analytics/experiments/{id}` | The same per variant, over the time the experiment ran; `widget_id` shows one of its widgets. |
| `DELETE` | `/core/widget-analytics/visitors/{anonymous_id}` | Deletes one visitor's analytics; returns the events and sessions removed. |


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