> 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/statsig.md).

# Statsig

The Statsig destination sends events to [Statsig](https://www.statsig.com/) using the server-side [`log_event` HTTP API](https://docs.statsig.com/api/content/api-reference/events/log-custom-events), so you can use Chord events as metrics for Statsig experiments and feature gates.

This is a server-side destination only, and deliberately so. The metrics that decide a Statsig experiment are revenue events, such as Order Completed, refunds and subscription renewals. Those events frequently arrive from back-end sources, such as Shopify webhooks and server-to-server ingest, that never touch a browser. A browser destination could not see them, which would leave you with an experiment that cannot measure its own success metric. Segment ships Statsig the same way, server-side only.

Feature gate and experiment evaluation stays in your storefront's own Statsig SDK. This destination only calls `log_event`. It never calls `check_gate`, because that endpoint automatically logs exposure events and would double-count exposures the storefront SDK already records.

## Getting started

In the Statsig console, copy a server secret key from **Project Settings > API Keys**. It starts with `secret-`. Do not use a client SDK key.

## Settings

* **Destination Name** (required): a name to tell this destination apart.
* **Server Secret Key** (required): your Statsig server secret key, which starts with `secret-`. Find it in **Project Settings > API Keys**. Do not use a client SDK key, because this destination runs server-side.
* **Environment Tier** (optional): the value sent as `user.statsigEnvironment.tier`. Events tagged with a non-production tier are excluded from production experiment metrics. Choose **Production** (default), **Staging** or **Development**.
* **Anonymous ID Key** (optional): the `user.customIDs` key that the visitor's `anonymousId` is sent under. It must match the unit ID your Statsig experiments are randomized on, or server-side events will not join to experiment groups. Defaults to `stableID`. Leave it as `stableID` unless your storefront passes a different custom ID. See [Identity and experiment units](#identity-and-experiment-units).
* **Value Property** (optional): the event property to send as the Statsig `value` field, used for revenue-style metrics. When set, Chord reads only this property. If empty, Chord uses `revenue`, then `total`, then `value`.
* **Email Handling** (optional): where a user's email address goes. Choose **Private (privateAttributes)** (default), **Attribute (user.email)** or **Omit**. See [Email and PII](#email-and-pii).
* **Send Page Events** (optional): send `page` events as a Statsig `Page View` event. On by default.
* **Send Identify Events** (optional): Statsig has no user-profile API, so identify calls are logged as an `Identify` event with traits in `metadata`. Off by default, to avoid inflating event volume.
* **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 **Statsig** from the destination catalog, using the settings above. See [Connect a destination](/activate/event-streaming/connect-a-destination.md) for the full steps.

## Identity and experiment units

This is the setting that most often breaks a Statsig integration, so it is worth getting right before you ship.

Statsig randomizes each experiment on a **unit ID**. If the storefront's Statsig SDK assigns a visitor to a variant using one ID, but Chord sends the conversion event under a different one, the event will not join to the experiment group. Every readout comes back flat, with no error anywhere to explain why.

The destination sends:

| Chord source (priority order)           | Statsig field                                  | Notes                                                          |
| --------------------------------------- | ---------------------------------------------- | -------------------------------------------------------------- |
| `userId`                                | `user.userID`                                  | Left out if the event has no User ID                           |
| `anonymousId`                           | `user.customIDs.<Anonymous ID Key>`            | Left out if the event has no anonymous ID                      |
| `traits.email` > `context.traits.email` | `user.email` or `user.privateAttributes.email` | Set by **Email Handling**. See [Email and PII](#email-and-pii) |
| `context.ip`                            | `user.ip`                                      |                                                                |
| `context.userAgent`                     | `user.userAgent`                               |                                                                |
| `context.locale`                        | `user.locale`                                  |                                                                |
| `context.geo.country.code`              | `user.country`                                 |                                                                |
| **Environment Tier**                    | `user.statsigEnvironment.tier`                 | See [Environments](#environments)                              |

The **Anonymous ID Key** defaults to `stableID`, which is Statsig's own convention for an anonymous unit. For this to line up, your storefront must be configured to pass the Chord `anonymousId` as Statsig's `stableID` rather than letting the Statsig SDK generate its own. If your experiments are randomized on a different custom ID, set the Anonymous ID Key to match it.

Migrating off Segment? Whatever field you mapped to Statsig's `userID` in the Segment destination is the unit your existing experiments are already keyed on. Carry that exact mapping over, or your readouts will break at cutover.

## Event mapping

Statsig has no fixed event taxonomy. Custom event names are first class, so **track events pass through under their own name**. There is no allowlist and no renaming.

| Chord event | Statsig event                  | Notes                                                           |
| ----------- | ------------------------------ | --------------------------------------------------------------- |
| `track`     | The Chord event name, verbatim | Custom events pass through unchanged                            |
| `page`      | `Page View`                    | Sent only when **Send Page Events** is on (default on)          |
| `identify`  | `Identify`                     | Sent only when **Send Identify Events** is on (default **off**) |

Any other event type (`group`, `screen` and so on) is skipped. A track event with no name is also skipped.

**Track events**

| Chord source (priority order)                                  | Statsig field | Notes                                                                                                                                       |
| -------------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `event`                                                        | `eventName`   | Passed through verbatim                                                                                                                     |
| `properties.revenue` > `properties.total` > `properties.value` | `value`       | Replaced by the **Value Property** setting when it is set. Numeric strings are converted to numbers. A value that isn't a number is skipped |
| `timestamp` > `receivedAt`                                     | `time`        | Unix milliseconds                                                                                                                           |
| `properties`                                                   | `metadata`    | See [Metadata flattening](#metadata-flattening)                                                                                             |
| Identity and context                                           | `user`        | See [Identity and experiment units](#identity-and-experiment-units)                                                                         |

**Page events**

| Chord source (priority order) | Statsig field                                     | Notes                                                                                                                                |
| ----------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| *(hardcoded)* `Page View`     | `eventName`                                       | Page identity lives in `metadata`, so a single metric can be filtered per page rather than fragmenting into one metric per page name |
| `context.page`                | `metadata.url` / `.path` / `.title` / `.referrer` | Explicit `properties` of the same name win over the context values                                                                   |
| `name`                        | `metadata.name`                                   | Present when the page event is named. An explicit `properties.name` wins                                                             |

`value` is never set on page events or identify events.

**Identify events**

Statsig has no user-profile API, so an identify call is logged as an ordinary `Identify` event with the user's traits in `metadata`. This is off by default to avoid inflating event volume for no analytical gain. Turn on **Send Identify Events** only if you want identify calls to be countable as a metric.

## Custom events

Every track event is sent to Statsig under its own name, with its properties in `metadata`.

## Metadata flattening

Statsig's `metadata` is a flat key/value map. Nested values (`products[]`, `address` and so on) are JSON-stringified rather than dropped, so the data still reaches Statsig and remains queryable as a string. Primitives (string, number, boolean) pass through unchanged. `null` and `undefined` are omitted.

Because `metadata` accepts arbitrary keys, any [property mappings](/activate/event-streaming/property-mappings.md) you configure flow through automatically. There is no destination-side schema to add them to.

## Email and PII

The **Email Handling** setting controls where a user's email address goes:

| Mode              | Behavior                                                                                               |
| ----------------- | ------------------------------------------------------------------------------------------------------ |
| Private (default) | Sent as `user.privateAttributes.email`. Usable for targeting, but never written to Statsig's event log |
| Attribute         | Sent as `user.email`, which **is** logged                                                              |
| Omit              | Never sent                                                                                             |

In Private and Omit mode, `email` is also stripped from `metadata`, so a value arriving through traits or properties cannot defeat the setting.

{% hint style="warning" %}
**Email Handling** covers email and nothing else. Every other trait and property is forwarded to `metadata` as is, and `metadata` is written to Statsig's event log. An identify event carrying `phone`, `firstName`, `lastName` or `address` sends those to Statsig in plaintext, with no setting to suppress them. This matters most for identify events, which carry a full trait set, and is one reason **Send Identify Events** is off by default. If a trait must not reach Statsig, drop it upstream in a [function](/activate/event-streaming/functions.md) rather than relying on this destination to filter it.
{% endhint %}

## Environments

The **Environment Tier** setting is sent as `user.statsigEnvironment.tier`. Set it to Staging or Development on non-production connections. Otherwise staging traffic silently pollutes your production experiment metrics, which is painful to unwind after the fact.

## Retry behavior

| Response          | Behavior                                                                                             |
| ----------------- | ---------------------------------------------------------------------------------------------------- |
| `2xx`             | Accepted (Statsig answers `202`)                                                                     |
| `429`, `5xx`      | Retried                                                                                              |
| Other `4xx`       | Not retried. A bad secret key or malformed payload cannot be fixed by sending the same request again |
| Transport failure | Retried                                                                                              |


---

# 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/statsig.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.
