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

# Agent lifecycle analytics

> Use the deduplicated ContactButton Agent journey in GA, GTM, and your own browser integrations.

ContactButton records one canonical lifecycle stream for hosted web Agents, REST, MCP, and A2A. The same public event ID is used for internal reporting and browser analytics, so retries and streaming reconnects do not create additional ContactButton events.

## Event names

The lifecycle includes:

* `opened`
* `conversation_started`
* `question_sent`
* `answer_completed`
* `answer_failed`
* `feedback`
* `contact_captured`
* `action_proposed`
* `action_completed`
* `action_failed`
* `handed_off`

Hosted web Agents project these events to `window.dataLayer` with an `event` value such as `contactbutton_agent_answer_completed`. ContactButton also dispatches a `contactbutton:agent-lifecycle` DOM event.

```js theme={null}
document.addEventListener('contactbutton:agent-lifecycle', (event) => {
  const lifecycle = event.detail;
  // lifecycle.event === 'contactbutton_agent_answer_completed'
});
```

The payload contains only:

```json theme={null}
{
  "event": "contactbutton_agent_action_completed",
  "event_id": "c62e80ca-d502-4d77-a19d-18383466a12f",
  "agent_id": "5fb3622d-c5db-427b-8500-4d79ea16ea09",
  "capability_id": "propose_booking",
  "protocol": "web",
  "page_context": "embedded"
}
```

Prompts, answers, email addresses, phone numbers, OTPs, credentials, and internal database IDs are never included.

## Consent and deduplication

If a ContactButton cookie banner is configured, embedded browser events are sent to GA/GTM only after analytics consent. The workspace **Disable user cookies** setting disables the customer browser projection. Canonical server events for the requested Agent service remain tenant-scoped and power ContactButton reporting.

Browsers remember the latest public event IDs and do not project the same event twice. Server events also have a unique idempotency fingerprint, so replayed API mutations and reconnects do not inflate the internal funnel.
