Experiment's end-to-end platform relies on two events:

* [Assignment events](#assignment-events): convert users into registered participants.
* [Exposure events](#exposure-events): indicate when a user experiences an experiment variant.

These two events, along with an [experiment user property](#experiment-user-properties) for each experiment, power experiment analysis, monitoring, and debugging.

Use the Amplitude-defined exposure or assignment events as your experiment's exposure event so Amplitude sets the correct [experiment user property](#experiment-user-properties) when it ingests the exposure. Amplitude might ingest custom exposure events before setting the experiment user property, so those events don't count in experiment analysis.

* **Assignment**:
  * Experiment tracks an assignment event when it assigns a user through remote evaluation (`fetch()`) or server-side local evaluation (`evaluate()`).
  * Contains assignment information for one or more flags and experiments.
  * Useful for monitoring and debugging, or as an exposure heuristic for server-side experiments.
* **Exposure**:
  * Experiment tracks an exposure event when a user encounters a variant. Typically on the client side when code accesses a variant from the SDK (`variant()`).
  * Contains exposure information for a single flag or experiment.
  * Acts as the exposure event for client-side experiments.
  * Sets the experiment user property for the exposed flag or experiment.

{% callout type="note" heading="Event volume billing and property limits" %}
Exposure (`[Experiment] Exposure`) and assignment (`[Experiment] Assignment`) events don't count toward your organization's event volume or Monthly Tracked Users (MTU).

If you use other events in place of `[Experiment] Exposure` or `[Experiment] Assignment`, those events do count toward your event volume and MTU.
{% /callout %}

## Experiment user properties

Experiment uses a user property for each flag and experiment, and exposure events set or unset this property. The user property lets Experiment determine which variant the user is in for experiment analysis. Amplitude supports up to 1500 experiment user properties for each project.

The user property format is `[Experiment] <flag_key>`, and the value is the variant key Experiment assigned or exposed the user to. Use this user property in queries for non-experiment events that occur after Experiment sets the property to segment by flag or experiment variant.

## Assignment events

Amplitude's evaluation servers or SDKs track assignment events through [remote evaluation](/docs/feature-experiment/remote-evaluation) or [local evaluation](/docs/feature-experiment/local-evaluation) using a server-side SDK configured for [automatic assignment tracking](#automatic-assignment-tracking). Use assignment events as a heuristic exposure event for server-side experiments, to monitor an active flag or experiment, and to debug issues. For server-side experiments where client-side exposure tracking isn't possible, choose the Amplitude Assignment event as the exposure event when you configure your experiment.

You shouldn't need to track assignment events manually.

### Assignment event definition

The assignment event, `[Experiment] Assignment`, contains an event property, `[Experiment] <flag_key>.variant`, for each evaluated flag or experiment. The property value is the assigned variant key, or `off` when Experiment assigns no variant.

The assignment event also contains properties such as `[Experiment] Environment Name` and `[Experiment] <flag_key>.details`, which support internal debugging.

{% callout type="example" heading="Example event JSON" %}
This example shows an assignment event for user `123456789`, evaluated for one flag `my-flag` and one experiment `my-experiment`.
```json
{
    "user_id": "123456789",
    "event_type": "[Experiment] Assignment",
    "event_properties": {
        "[Experiment] my-flag.variant": "off",
        "[Experiment] my-experiment.variant": "treatment"
    }
}
```
{% /callout %}

### Automatic assignment tracking

Experiment supports automatic assignment tracking for [remote evaluation](/docs/feature-experiment/remote-evaluation) by default. Remote evaluation requests that miss the CDN cache and contain a valid user or device ID trigger an asynchronous assignment event after evaluation.

For server-side [local evaluation](/docs/feature-experiment/local-evaluation), configure the local evaluation SDK on initialization to track assignment events on `evaluate()`. Amplitude deduplicates assignment events from server-side local evaluation SDKs for each user using an `insert_id` that contains the user ID, device ID, a hash of the canonicalized list of assigned flags and variants, and the date stamp.

Expect one assignment per evaluated user, per unique evaluation result, per day.

| SDK | Minimum version |
| --- | --- |
| [Node.js](/docs/sdks/experiment-sdks/experiment-node-js) | `1.7.4+` |
| [Ruby](/docs/sdks/experiment-sdks/experiment-ruby) | `1.2.2+` |
| [JVM](/docs/sdks/experiment-sdks/experiment-jvm) | `1.2.1+` |
| [Go](/docs/sdks/experiment-sdks/experiment-go) | `1.2.2+` |
| [Python](/docs/sdks/experiment-sdks/experiment-python) | `1.2.3+` |

## Exposure events

An exposure event is a [strictly defined](#exposure-event-definition) analytics event that tells Experiment a user encountered a variant of an [experiment or feature flag](/docs/feature-experiment/data-model#flags-and-experiments). Exposure events carry the flag key and the variant the user encountered in the event's properties.

When Amplitude ingests an exposure event, it uses the flag key and variant to set or unset user properties on the associated user. These user properties power experiment analysis queries on primary and secondary success metrics.

### Exposure event definition

You can send the exposure event through any analytics implementation or customer data platform without manipulating user properties.

| Event type | Event property | Requirement | Description |
| --- | --- | --- | --- |
| **`$exposure`** | `flag_key` | Required | The flag or experiment key the user encounters. |
| | `variant` | Optional | The variant of the flag or experiment the user encounters. If `null` or missing, Amplitude unsets the user property for the flag or experiment, and the user is no longer part of the experiment. |
| | `experiment_key` | Optional | The key of the experiment the user encounters. The experiment key differentiates between two [runs of an experiment on the same flag key](/docs/feature-experiment/troubleshooting/new-experiment-run). |

{% callout type="example" heading="Example event JSON" %}
This example shows an exposure event for user `123456789`, who encountered the `treatment` variant of the experiment `my-experiment`.
```json
{
    "user_id": "123456789",
    "event_type": "$exposure",
    "event_properties": {
        "flag_key": "my-experiment",
        "variant": "treatment"
    }
}
```
{% /callout %}

#### Exposure transformation

When Amplitude ingests an `$exposure` event, Amplitude transforms it. Amplitude renames the event type and event properties for consistency with other Amplitude properties, then sets or unsets [experiment user properties](#experiment-user-properties) for accurate experiment analysis.

| Property type | Pre-transformation | Post-transformation |
| --- | --- | --- |
| Event type | `$exposure` | `[Experiment] Exposure` |
| Event property | `flag_key` | `[Experiment] Flag Key` |
| Event property | `variant` | `[Experiment] Variant` |
| Event property | `experiment_key` | `[Experiment] Experiment Key` |

### Automatic exposure tracking

Client-side Experiment SDKs support automatic exposure tracking through an exposure tracking provider implementation. Without an integration or custom implementation, Experiment doesn't track exposure events automatically.

| SDK integrations | Minimum version |
| --- | --- |
| [JavaScript SDK](/docs/sdks/experiment-sdks/experiment-javascript#integrations) | `1.4.1+` |
| [Android SDK](/docs/sdks/experiment-sdks/experiment-android#integrations) | `1.5.1+` |
| [iOS SDK](/docs/sdks/experiment-sdks/experiment-ios#integrations) | `1.6.0+` |
| [React Native](/docs/sdks/experiment-sdks/experiment-react-native#integrations) | `0.6.0+` |

### Exposure tracking example

{% api-tester type="exposure-tracking" / %}

### Proxy exposure events

A proxy exposure event is a normal analytics event you select to model traffic and baseline conversion before an experiment runs. Proxy exposure events power the duration estimator and related calculations. Proxy exposure events aren't the same as the actual exposure or assignment events Amplitude uses during analysis after an experiment goes live.

Choose a proxy exposure event that best represents when a user might encounter your experiment experience. Amplitude uses historical traffic to estimate experiment duration and set baselines when the flag is inactive. The [duration estimator](/docs/feature-experiment/workflow/experiment-estimate-duration) relies on the proxy exposure event's recent traffic. Amplitude computes the "control mean" baseline from users who completed the proxy exposure event during the seven days before the experiment starts.

The activity log records proxy exposure changes, so configuration changes appear in the flag history.

Amplitude stores proxy exposure events in analysis parameters as a single `ExposureEvent`-shaped object, distinct from the array of actual exposure events.

{% callout type="tip" heading="Proxy events with Experiment SDK" %}
If you use Experiment SDKs and call `.variant()` or configure the ExposureTrackingProvider, Amplitude can automatically track exposure events. Alternatively, call `exposure()` to explicitly log exposures using the cached variant. Calling `exposure()` doesn't automatically create or set the proxy exposure. You must select a normal analytics event as your proxy.
{% /callout %}
