> 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/experimentation/metrics/setup/index.md).

# Setup

A metric is a measurement of success for your experiment across your website, application, or backend services. Metrics can help you understand whether a feature flag improves, degrades, or has no measurable impact on customer behavior or experience.

Metrics are calculated using impressions and events:

* [Impressions](/feature-management-experimentation/use-fme/feature-management/monitoring-and-analysis/impressions.md) occur when a visitor is assigned a treatment for a feature flag.
* [Events](/feature-management-experimentation/use-fme/experimentation/events/index.md) capture actions or measurements such as clicks, views, purchases, or performance data.

Once metrics are attached to feature flags and event data is flowing, you can confidently evaluate experiments, manage risk, and make data-driven product decisions in Harness FME.

You can create a metric, configure alerts, and analyze impact in six steps:

1. [Define your metric name and information](#define-your-metric-name-and-information)
2. [Define your metric definition](#define-your-metric-definition)
3. [Create an alert policy](#create-an-alert-policy)
4. [Manage alerts](#manage-alerts)
5. [Review metrics impact during a review period](#review-metrics-impact-during-a-review-period)
6. [Analyze metric impact details and trends over time](#analyze-metric-impact-details-and-trends-over-time)

### Define your metric name and information <a href="#define-your-metric-name-and-information" id="define-your-metric-name-and-information"></a>

To create a metric in Harness FME:

1. Navigate to the **Metrics** page from the Harness FME navigation menu and click **+ Create metric**.
2. Provide the following information:
   * **Name**: Enter a descriptive metric name.
   * **Owners**: Select one or more Harness FME users as metric owners. Owners can filter metrics using **Owned by me**.
   * **Tags**: Optionally, add tags to help organize metrics by team, feature, or release.
   * **Description**: Optionally, describe what the metric measures and why it exists.
   * **Metric category**: Select **None** (default) or **Guardrail**, which applies account-wide alerting settings. Go to [Metric categories](/feature-management-experimentation/use-fme/release-monitoring/metrics/categories/index.md) to review the available categories.

### Define your metric definition <a href="#define-your-metric-definition" id="define-your-metric-definition"></a>

The metric definition determines how Harness FME calculates the metric and which direction counts as an improvement. To define your metric:

1. In the **Select the desired impact** field, select whether you want this metric to increase or decrease. Select *increase* if a higher measurement is good for your business and customer experience, and *decrease* if it is not. In most A/B testing tools, this is the winning direction.
2. In the **Select traffic type** field, select the traffic type of the event you want to measure. This is the traffic type you specify when you send the event to Harness FME, and it is also the traffic type defined for the feature flags that show the metric results on the Metrics impact tab. The traffic type for the metric must match the traffic type for the feature flag you want it applied to. Go to [Traffic types](/feature-management-experimentation/management-and-administration/traffic-types.md) to review how traffic types are defined.
3. In the **Measured as** field, select the type of calculation to perform on the event, the event value, or an event property. These functions are performed per your traffic type. Go to [Statistical comparison (Measured per user)](#statistical-comparison-measured-per-user) for each available function and an example of its use.
4. In the **Event** field, select an event type to use in the metric calculation. To use more than one event in the metric, click **Add event**. To filter the selected event by a property, click **Add new filter**. For example, to count page views from California, select an event called `page.view` with a property filter of `state` matches `California`. You can use [RE2 syntax](https://github.com/google/re2/wiki/Syntax) for regular expressions in your filter.
5. In the **Value** field, optionally select the property to use as the value field. For a sum or average metric, you can select either the event value or a property value for the calculation. Go to [Event properties](/feature-management-experimentation/use-fme/experimentation/events/index.md#event-properties) to review the available properties.
6. In the **Properties** field, optionally define the event properties to filter by when measuring this metric. Go to [Event properties](/feature-management-experimentation/use-fme/experimentation/events/index.md#event-properties) to review the available properties.

#### Statistical comparison (Measured per user) <a href="#statistical-comparison-measured-per-user" id="statistical-comparison-measured-per-user"></a>

When calculating metrics per user, each user's individual contribution is calculated first. Each user then adds a single data point to the distribution of the user metric results, so every user carries the same weight in the result. Harness FME uses the resulting distribution for statistical testing of the metrics below.

All the examples assume that users are used for the traffic type in the experiment, and that the users were exposed to a particular treatment of a particular feature flag version. Where the examples state "for each user", the same logic applies to whichever traffic type you are using at the time.

Go to [Metric types](/feature-management-experimentation/use-fme/release-monitoring/metrics/index.md#metric-types) for an extended description of how each function behaves as an experiment runs.

|                     Function                    |                                                    Description                                                   |                                                                                Example                                                                                |
| :---------------------------------------------: | :--------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|       Count of events per \[traffic type]       |                  For each traffic type, the number of times they perform an event is calculated.                 |    <p>Measure the average number of times a user visits your website.<br><br>Measure the average number of support tickets a user files with your support team.</p>   |
|     Sum of event values per \[traffic type]     |                        For each traffic type, the sum of their event values is calculated.                       |           <p>Measure the total value of items purchased by a user.<br><br>Measure the total number of minutes a user listened to media on your website.</p>           |
| Average of the event values per \[traffic type] |                   For each traffic type, the average value of the user's events is calculated.                   |                       <p>Measure the average value of items a user purchases.<br><br>Measure the average page load time a user experiences.</p>                       |
|     Ratio of two events per \[traffic type]     |     For each traffic type, the ratio of the number of times two different events are performed is calculated.    | <p>Measure the number of hotel searches that occur for a user to make a hotel booking.<br><br>Measure the number of invites sent for a user to accept the invite.</p> |
|        Percent of unique \[traffic type]        | The number of distinct traffic types that performed the event as a percent of those in the sample is calculated. |              <p>Measure what percent of your sample size clicked the checkout button.<br><br>Measure the percent of users who filed a support ticket.</p>             |

#### Advanced metric settings <a href="#advanced-metric-settings" id="advanced-metric-settings"></a>

In the **Advanced** section of a metric definition, optionally apply the following settings:

* **Filter by**: Restrict the customers counted in the metric to those who triggered another event.
  * **No filter criteria**: No filters are applied.
  * **Has done the following event prior to the metric event**: Counts customers who triggered the filter event at least once during the version of a feature flag, as long as it happened within the same feature flag version and before the metric event. For example, to measure the count of add to cart events that happened after a customer viewed the special offers page, select **Added to cart** for the metric event and **Viewed special offers page** for the filter event.
  * **Has done the following event (not ordered)**: Counts customers who triggered the filter event at least once during the version of a feature flag. As long as a customer triggered the event within the same feature flag version, the filter applies even if the event happened after the metric event. For example, to measure the count of add to cart events that happened either before or after a customer subscribed to the newsletter, select **Added to cart** for the metric event and **Subscribed to newsletter** for the filter event.
  * **Properties**: Optionally apply a property filter to the event you are filtering the metric by.
* **Cap at**: Apply a cap to your metric value to reduce the impact of outliers. Capping replaces outlier values in your metric with a fixed threshold value, which reduces the variance and increases the sensitivity of the metric.

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>When a metric cap is set to per user per day, the day is the 24 hours from a user's first impression within a particular version of a feature flag.</p></div>

### Create an alert policy <a href="#create-an-alert-policy" id="create-an-alert-policy"></a>

An alert policy allows you to configure a degradation threshold for your metric. If the feature flag causes the metric to go below or above that threshold, you are alerted through your configured notification channel. Go to [Alert policies](/feature-management-experimentation/use-fme/experimentation/metrics/alert-policies.md) to create one.

### Manage alerts <a href="#manage-alerts" id="manage-alerts"></a>

Any alerts that are triggered are displayed on both the Targeting tab and the Alerts tab on the feature flag page. When you receive an alert, you can roll the feature flag back by clicking kill, or you can dismiss the alert. Go to [Creating a metric alert policy](/feature-management-experimentation/use-fme/release-monitoring/metrics/setup/metric-alert-policy.md) to configure what triggers an alert and who is notified.

### Review metrics impact during a review period <a href="#review-metrics-impact-during-a-review-period" id="review-metrics-impact-during-a-review-period"></a>

The review periods are preset in the admin settings. To access your metrics impact, search for the feature flag you want to see the impact for and go to its Metrics impact tab. The impact on your metrics is ordered by feature flag key metrics first, then account-wide guardrail metrics, and then feature flag supporting metrics. Go to [Review period check](/feature-management-experimentation/use-fme/experimentation/experiment-results/analyzing-experiment-results/review-period-check.md) to understand how the review period is applied, and to [Filtering your metrics](/feature-management-experimentation/use-fme/release-monitoring/metrics/setup/filtering.md) to narrow the results.

### Analyze metric impact details and trends over time <a href="#analyze-metric-impact-details-and-trends-over-time" id="analyze-metric-impact-details-and-trends-over-time"></a>

Information such as the impact %, the p-value, and the error margin is surfaced on the metric card. Click the metric card to access additional information, including how the impact changed over time, the metric dispersion, and the sample size used to calculate the metric value. Go to [Understanding results](/feature-management-experimentation/use-fme/experimentation/experiment-results/viewing-experiment-results/metrics-impact-cards.md) to interpret these values.

### Audit logs <a href="#audit-logs" id="audit-logs"></a>

Audit logs are captured every time the metric's definition or alert policy is changed. Go to [Audit logs](/feature-management-experimentation/management-and-administration/audit-logs.md) to review the captured changes.

{% @harness-feedback/feedback %}
