> For the complete documentation index, see [llms.txt](https://docs.chord.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chord.co/activate/event-streaming/destinations/analytics/heap/heap-browser.md).

# Heap browser

This destination loads the Heap browser SDK directly in the visitor's browser and sends events client-side. Unlike the [Heap server](/activate/event-streaming/destinations/analytics/heap/heap-server.md) version, events originate from the browser, which enables Heap's automatic interaction capture, session replay and heatmap features. See [Heap](/activate/event-streaming/destinations/analytics/heap.md) for how the two fit together.

## Getting started

You don't need to install a script yourself. You need one value:

* **App ID (Environment ID)**: found in **Account > Manage > Projects** in the Heap dashboard. Each project (environment) has its own App ID.

## Settings

* **Destination Name** (required): a name to tell this destination apart.
* **App ID** (required): your Heap Environment ID, found in **Account > Manage > Projects** in the Heap dashboard.
* **Consent Requirements** (optional): the consent categories a visitor must accept before Chord sends data to this destination. See [Consent](/activate/event-streaming/consent.md).

## Connect

Add **Heap (Device Mode)** from the destination catalog, using the settings above. See [Connect a destination](/activate/event-streaming/connect-a-destination.md) for the full steps.

## Event mapping

| Chord event | Heap event                                                   | Notes                                         |
| ----------- | ------------------------------------------------------------ | --------------------------------------------- |
| `track`     | `heap.track(eventName, properties)`                          | Event name and properties forwarded as-is     |
| `page`      | `heap.track("Page View", properties)`                        | Page details added to the properties          |
| `identify`  | `heap.identify(identity)` + `heap.addUserProperties(traits)` | Identity resolved from `userId` > email trait |

**Track events**

| Chord source (priority order) | Heap field   | Notes                          |
| ----------------------------- | ------------ | ------------------------------ |
| `event` (event name)          | `eventName`  |                                |
| `properties`                  | `properties` | All event properties forwarded |

**Page events**

| Chord source (priority order) | Heap field            | Notes                                                      |
| ----------------------------- | --------------------- | ---------------------------------------------------------- |
| *(hardcoded)* `"Page View"`   | `eventName`           |                                                            |
| `properties`                  | `properties`          | All event properties forwarded, plus the four fields below |
| `name`                        | `properties.name`     | The page name                                              |
| `context.page.url`            | `properties.url`      |                                                            |
| `context.page.path`           | `properties.path`     |                                                            |
| `context.page.referrer`       | `properties.referrer` |                                                            |

**Identify events**

| Chord source (priority order)         | Heap field                       | Notes                                                                                                                                        |
| ------------------------------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `userId` > `context.traits.email`     | `heap.identify(identity)`        | Skipped if neither is present                                                                                                                |
| `traits` merged with `context.traits` | `heap.addUserProperties(traits)` | All traits forwarded, including email. If a trait is in both, `traits` wins. Sent whenever there are traits, even when no identity was found |

## Custom events

Every track event is sent to Heap under its own name, with all its properties.

## Initialization

On the first event, Chord loads the Heap script for your App ID from `https://cdn.heapanalytics.com/js/heap-{appId}.js`. Events that arrive while the script is loading wait for it to finish. If the script fails to load, a warning is logged in the browser console and later events are dropped.

## CSP requirements

If your site uses a Content Security Policy, allow the following domains:

| Directive     | Domain                                                      |
| ------------- | ----------------------------------------------------------- |
| `script-src`  | `https://cdn.heapanalytics.com`                             |
| `connect-src` | `https://cdn.heapanalytics.com` `https://heapanalytics.com` |
| `img-src`     | `https://heapanalytics.com`                                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chord.co/activate/event-streaming/destinations/analytics/heap/heap-browser.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
