---
title: Manage Subject Types
description: >-
  Configure subject types so Datadog can randomize experiments and join
  exposures to metrics.
breadcrumbs: Docs > Experiments > Manage Subject Types
---

# Manage Subject Types

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site.md). ({% placeholder "user-datadog-site-name" /%}).
{% /alert %}

{% /callout %}

## Overview{% #overview %}

Use this page to configure subject types, the unit Datadog uses to randomize experiment traffic, such as a user or an organization.

Experiments assign traffic to different variations of an experience and measure outcomes across those groups. Subjects are users by default, but you can define other randomization units.

For a given subject, the Datadog SDK returns the same variant on every evaluation, keeping the experience consistent across sessions and devices.

Subject types also determine how Datadog associates metric events with experiment exposures for statistical analysis.

## Specify the subject identifier in code{% #specify-the-subject-identifier-in-code %}

When you use the Datadog SDK, pass a unique identifier for the experiment subject as the `targetingKey`:

```js
const evaluationContext = {
    targetingKey: 'user_1234',
};
```

Randomization uses deterministic hashing. Each time the user returns to the application, Datadog assigns the same variant as long as the user remains eligible based on targeting rules.

## Map experiment exposures to metrics{% #map-experiment-exposures-to-metrics %}

When you [plan an experiment](https://docs.datadoghq.com/experiments/plan_and_launch_experiments.md), select the appropriate subject type:

{% image
   source="https://docs.dd-static.net/images/product_analytics/experiment/subject_types/select_subject_type.346f8161bba7e54fcc455cafab53f775.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/product_analytics/experiment/subject_types/select_subject_type.346f8161bba7e54fcc455cafab53f775.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The experiment setup page with the subject type selector above primary metric selection, showing User and Organization options." /%}

By default, Datadog includes a **User** subject type. To manage subject types, navigate to **Experiments** > **Settings** > **Subject Types**:

{% image
   source="https://docs.dd-static.net/images/product_analytics/experiment/subject_types/subject_type_list.7e3e6c4c0f65c268fc6a6109bb30f611.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/product_analytics/experiment/subject_types/subject_type_list.7e3e6c4c0f65c268fc6a6109bb30f611.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Subject Types settings page listing User and Organization subject types." /%}

### Warehouse metrics{% #warehouse-metrics %}

When you configure [Metric SQL Models](https://docs.datadoghq.com/experiments/defining_metrics.md?tab=warehouse#create-a-sql-model), map warehouse columns to subject types in the right panel:

{% image
   source="https://docs.dd-static.net/images/product_analytics/experiment/subject_types/sql_model_setup.e7b86904f7ce0f37d385092a53016331.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/product_analytics/experiment/subject_types/sql_model_setup.e7b86904f7ce0f37d385092a53016331.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Metric SQL Model setup page with warehouse columns mapped to subject types in the right panel." /%}

{% alert level="info" %}
If you add a default warehouse column ID on the Subject Types page (for example, `user_id`), Datadog automatically maps columns with that name to the matching subject type.
{% /alert %}

Datadog writes experiment exposures to the `g_exposures` table in the output schema you configure when you [connect your warehouse](https://docs.datadoghq.com/experiments/guide/connecting_a_data_warehouse.md). Datadog joins that table to your Metric SQL on the subject column you mapped above. Values in the subject column must match the `targetingKey` you pass with the Datadog SDK.

For example, if a Metric SQL Model uses a `user_id` column for the experiment subject type, Datadog analyzes results with SQL similar to the following:

```sql
WITH assignments AS (
    -- Assignment deduplication and date filtering omitted for brevity
    SELECT * FROM g_exposures
),
measures AS (
    -- Your Metric SQL Model logic goes here
)
SELECT
    ...
FROM assignments
LEFT JOIN measures
    ON assignments.subject_id = measures.user_id
    AND measures.timestamp BETWEEN assignments.timestamp AND {{experiment_end_timestamp}}
```

### Product Analytics and RUM metrics{% #product-analytics-and-rum-metrics %}

Each subject type has an associated **attribute**. Datadog uses this attribute to associate Product Analytics and Real User Monitoring (RUM) data with experiment exposures. The attribute value must match the identifier you pass as `targetingKey`.

For example:

```js
const evaluationContext = {
    targetingKey: 'user_1234',
};

datadogRum.setUser({
    id: 'user_1234',
    name: 'John Doe',
    email: 'john@doe.com',
    plan: 'premium',
    ...
});
```

When Datadog computes experiment results, it joins experiment exposures to Product Analytics and RUM events on the subject type attribute. By default, the analysis includes events that occur between a subject's first exposure and the end of the experiment. Datadog aggregates those events using the metric definition you configured (for example, count or sum), then runs a [statistical analysis](https://docs.datadoghq.com/experiments/analysis_methods.md) for the experiment.

## Further reading{% #further-reading %}

- [Plan and Launch Experiments](https://docs.datadoghq.com/experiments/plan_and_launch_experiments.md)
- [Create Experiment Metrics From Warehouse Data](https://docs.datadoghq.com/experiments/defining_metrics.md?tab=warehouse)
- [Read Experiment Results](https://docs.datadoghq.com/experiments/reading_results.md)
- [Connect your data warehouse](https://docs.datadoghq.com/experiments/guide/connecting_a_data_warehouse.md)
