> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/feature-management-experimentation/use-fme/warehouse-native-experimentation/setup/metric-sources.md).

# Preparing Metric Source Tables for Warehouse Native Experimentation

To prepare a [Metric Source](/feature-management-experimentation/use-fme/warehouse-native-experimentation/setup/configure-metrics.md) for Warehouse Native Experimentation, transform your raw event logs into a clean, standardized table that serves as the foundation for calculating metrics.

This page describes the required fields, recommended fields, and best practices for preparing your metric source tables.

### Required columns <a href="#required-columns" id="required-columns"></a>

{% hint style="info" %}
These fields are mandatory. Without them, Harness FME cannot define and calculate metrics.
{% endhint %}

Every Metric Source table must include the following columns:

| **Column**          | **Type**                 | **Description**                                                                                                                                                                                                                                                                                                       |
| ------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Unique Key**      | `STRING`                 | Unique identifier for the unit of randomization (e.g., `user_id`, `account_id`, or custom key). Must align with the key in the Assignment Source.                                                                                                                                                                     |
| **Event Timestamp** | `DATETIME` / `TIMESTAMP` | <p>The time the event occurred. Must be provided in epoch milliseconds or UTC format (e.g. <code>1714953600000</code> or <code>2026-05-05T00:00:00Z</code>).<br><br>Must align with the timestamp format used in the <a href="/pages/gcQjRRQE1SOgvKUpXLg5">Assignment Source</a> for accurate joins and analysis.</p> |
| **Event Name**      | `STRING`                 | The type of event (e.g., `purchase`, `page_view`, `add_to_cart`).                                                                                                                                                                                                                                                     |

### Recommended columns <a href="#recommended-columns" id="recommended-columns"></a>

While not required, these fields make debugging, filtering, and governance more efficient.

| **Column**                 | **Type**                       | **Description**                                                                                                                                                                                                                                             |
| -------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Event Value**            | `FLOAT` / `INTEGER`            | For metrics like revenue or page load time. Examples: order amount in USD, page load time in seconds. Required for aggregation in average and sum metrics.                                                                                                  |
| **Properties (flattened)** | `STRING`, `BOOLEAN`, `NUMERIC` | Useful for filtering metrics (e.g., `country`, `device_type`, `plan_tier`).                                                                                                                                                                                 |
| **Environment ID**         | `STRING`                       | Separate prod/staging data when the same event schema is used. When configuring a Metric Source in FME, you can map column values to a Harness environment or hard-code a single environment. Metrics automatically filter by the experiment’s environment. |
| **Traffic Type**           | `STRING`                       | Distinguishes the unit type (e.g., `user`, `account`, `anonymous`). Align with Assignment Sources when experiments randomize on different units.                                                                                                            |

### Common raw table schemas <a href="#common-raw-table-schemas" id="common-raw-table-schemas"></a>

#### Web/App Analytics Event Logs <a href="#webapp-analytics-event-logs" id="webapp-analytics-event-logs"></a>

| **Example Raw Schema**                                                                                                 | **Transformations**                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>user\_id</code><br><code>event\_name</code><br><code>event\_time</code><br><code>properties (JSON)</code></p> | <p>• Flatten properties into columns for key attributes used in metrics (e.g., <code>properties.amount</code> → <code>event\_value</code>, <code>properties.tier</code> → <code>plan\_type</code>).<br>• Standardize <code>event\_time</code> → <code>event\_timestamp</code>.<br>• Ensure event names are consistent (<code>purchase</code> vs <code>checkout\_completed</code>).</p> |

#### E-commerce Transaction Logs <a href="#e-commerce-transaction-logs" id="e-commerce-transaction-logs"></a>

| **Example Raw Schema**                                                                                                                         | **Transformations**                                                                                                                                                                                                                                                          |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>user\_id</code><br><code>order\_id</code><br><code>order\_time</code><br><code>order\_amount</code><br><code>order\_status</code></p> | <p>• Map <code>order\_time</code> → <code>event\_timestamp</code>.<br>• Set <code>event\_name = 'purchase'</code>.<br>• Use <code>order\_amount</code> as <code>event\_value</code>.<br>• Filter only completed/valid orders (<code>order\_status = 'completed'</code>).</p> |

#### Custom Business Event Tables <a href="#custom-business-event-tables" id="custom-business-event-tables"></a>

| **Example Raw Schema**                                                                                                 | **Transformations**                                                                                                                                                                               |
| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>account\_id</code><br><code>metric\_type</code><br><code>metric\_value</code><br><code>created\_at</code></p> | <p>• Map <code>account\_id</code> → <code>key</code>.<br>• Map <code>metric\_type</code> → <code>event\_name</code>.<br>• Standardize <code>metric\_value</code> → <code>event\_value</code>.</p> |

### Prepare your metric table <a href="#prepare-your-metric-table" id="prepare-your-metric-table"></a>

Follow these best practices for preparing your metric table in your data warehouse.

* **Consistency with Assignment Source**: Use the same key (`user_id`, `account_id`) in both tables. This is critical for joining exposures to outcomes.
* **De-duplication**: Remove duplicate event logs, which is common in streaming pipelines. Define uniqueness as (`user_id`, `event_name`, `event_timestamp`, `value`) when possible.
* **Timestamp Format**: `event_timestamp` must be in epoch milliseconds or UTC (ISO 8601).
* **Use UTC Consistently**: Always store `event_timestamp` in UTC.
* **Flatten Properties Early**: JSON blobs are flexible but slow in downstream queries. Extract only the fields needed for metrics (e.g., `amount`, `plan_tier`, `country`).
* **Event Naming Conventions**: Standardize event names across products and teams. Avoid mixing singular and plural (for example: `purchase` vs `purchases`).
* **Partitioning and Indexing**: Partition large tables by `DATE(event_timestamp)`. Cluster or index by `user_id` or `event_name` for efficient joins with Assignment Sources.
* **Value Handling**: Handle nulls carefully—exclude them or treat them as `0`, depending on the metric's intent. Ensure numeric fields (for example, `event_value`) use consistent units (for example, always USD, not mixed currencies).

### Example prepared table schema <a href="#example-prepared-table-schema" id="example-prepared-table-schema"></a>

| **Column**         | **Type**                         | **Notes**                                 |
| ------------------ | -------------------------------- | ----------------------------------------- |
| `user_id`          | `STRING`                         | Required                                  |
| `event_timestamp`  | `TIMESTAMP`                      | Required                                  |
| `event_name`       | `STRING`                         | Required                                  |
| `event_value`      | `FLOAT`                          | Required for average and sum metric types |
| `any_custom_field` | `STRING` / `BOOLEAN` / `NUMERIC` | Optional (flattened from properties)      |
| `environment_id`   | `STRING`                         | Recommended                               |
| `traffic_type`     | `STRING`                         | Optional                                  |

Once your Metric Source tables are prepared and validated, see [Setting Up an Metric Source](/feature-management-experimentation/use-fme/warehouse-native-experimentation/setup/index.md) to connect them in Harness FME.
