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

# Consent modes: integrate with your cookie banner

> HelpAlive ships with consent-aware tracking. Pause analytics until your cookie banner resolves and toggle consent at runtime — auto and required modes.

HelpAlive supports two consent modes and a runtime toggle so you can integrate with whatever consent banner or compliance flow you already run.

## Modes

| Mode                 | Behavior                                                                                                             |
| -------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **Auto** (default)   | HelpAlive starts capturing as soon as the script loads. Use this where your local rules don't require prior consent. |
| **Consent required** | HelpAlive loads but stays silent until you call `setConsent()` with permission.                                      |

Set the default in **Settings → Privacy Management** in your dashboard. HelpAlive picks it up automatically.

## Runtime toggle

Even in auto mode, you can change consent at any time — useful when a user updates their preferences in your privacy center.

```javascript theme={null}
// User accepts cookies
HelpAlive.setConsent({ analytics: true, chat: true });

// User rejects analytics but allows the chatbot
HelpAlive.setConsent({ analytics: false, chat: true });

// User rejects everything
HelpAlive.setConsent({ analytics: false, chat: false });
```

| Field       | Effect when `false`                                                                      |
| ----------- | ---------------------------------------------------------------------------------------- |
| `analytics` | HelpAlive stops recording activity for this user. Anything queued but unsent is dropped. |
| `chat`      | The AI assistant disappears entirely until consent is granted again.                     |

## Wiring it to your cookie banner

```javascript theme={null}
// 1. Set consent mode to "Required" in your HelpAlive dashboard so the
//    script loads but stays silent until you call setConsent().

// 2. Show your cookie banner and pass the choices through.
showConsentBanner({
  onAccept: (choices) => {
    HelpAlive.setConsent({
      analytics: choices.analytics === true,
      chat:      choices.chat === true
    });
  },
  onReject: () => {
    HelpAlive.setConsent({ analytics: false, chat: false });
  }
});
```

## GDPR-style explicit opt-in

For EU traffic where prior consent is required:

1. Set the project's default consent mode to **Required** in the dashboard.
2. Don't call `identify()` until the user accepts.
3. Call `setConsent({ analytics: true, chat: true })` and then `identify()` in your accept handler.

```javascript theme={null}
function onAccept(user) {
  HelpAlive.setConsent({ analytics: true, chat: true });
  HelpAlive.identify({
    userId:   user.id,
    tenantId: user.tenantId
  });
}
```

## Logout

Logging the user out clears identity automatically. If you want to also revoke consent on logout (useful for shared-device scenarios), call `setConsent` with both flags off as part of your logout flow:

```javascript theme={null}
function logout() {
  HelpAlive.setConsent({ analytics: false, chat: false });
  // …your logout logic
}
```

## What's stored when the user says no

Nothing. With `analytics: false`:

* No activity is recorded.
* No session is created.
* No device fingerprint, IP, or browser data is collected.

With `chat: false`, the AI assistant doesn't appear at all — the widget never loads on the page.

## Next steps

<CardGroup cols={2}>
  <Card title="Privacy overview" icon="shield-check" href="/privacy/overview">
    What we collect, what we don't, and where personal data is removed.
  </Card>

  <Card title="Data deletion" icon="trash" href="/privacy/dsar">
    Delete a user's data on request, with a full audit trail.
  </Card>
</CardGroup>
