Create metric

POST
/api/v2/metrics/:projectKey

Create a new metric in the specified project. The expected POST body differs depending on the specified kind property.

Path parameters

projectKeystringRequired

The project key

Request

This endpoint expects an object.
keystringRequired

A unique key to reference the metric

kindenumRequired
Allowed values: pageviewclickcustom

The kind of event your metric will track

namestringOptional

A human-friendly name for the metric

descriptionstringOptional

Description of the metric

selectorstringOptional

One or more CSS selectors. Required for click metrics only.

urlslist of objectsOptional

One or more target URLs. Required for click and pageview metrics only.

isActivebooleanOptional

Whether the metric is active. Set to true to record click or pageview metrics. Not applicable for custom metrics.

isNumericbooleanOptional

Whether to track numeric changes in value against a baseline (true) or to track a conversion when an end user takes an action (false). Required for custom metrics only.

unitstringOptional

The unit of measure. Applicable for numeric custom metrics only.

eventKeystringOptional

The event key to use in your code. Required for custom conversion/binary and custom numeric metrics only.

successCriteriaenumOptional
Allowed values: HigherThanBaselineLowerThanBaseline

Success criteria. Required for custom numeric metrics, optional for custom conversion metrics.

tagslist of stringsOptional

Tags for the metric

randomizationUnitslist of stringsOptional

An array of randomization units allowed for this metric

maintainerIdstringOptional

The ID of the member who maintains this metric

unitAggregationTypeenumOptional
Allowed values: averagesum

The method by which multiple unit event values are aggregated

analysisTypestringOptional

The method for analyzing metric events

percentileValueintegerOptional

The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.

eventDefaultobjectOptional

Response

Metric response

_idstring

The ID of this metric

_versionIdstring

The version ID of the metric

keystring

A unique key to reference the metric

namestring

A human-friendly name for the metric

kindenum
Allowed values: pageviewclickcustom

The kind of event the metric tracks

tagslist of strings

Tags for the metric

_creationDatelong

Timestamp of when the metric was created

experimentCountintegerOptional

The number of experiments using this metric

metricGroupCountintegerOptional

The number of metric groups using this metric

_attachedFlagCountintegerOptional

The number of feature flags currently attached to this metric

_siteobjectOptional

Details on how to access the metric in the LaunchDarkly UI

_accessobjectOptional

Details on the allowed and denied actions for this metric

lastModifiedobjectOptional
maintainerIdstringOptional

The ID of the member who maintains this metric

_maintainerobjectOptional

Details on the member who maintains this metric

descriptionstringOptional

Description of the metric

categorystringOptional

The category of the metric

isNumericbooleanOptional

For custom metrics, whether to track numeric changes in value against a baseline (true) or to track a conversion when an end user takes an action (false).

successCriteriaenumOptional
Allowed values: HigherThanBaselineLowerThanBaseline

For custom metrics, the success criteria

unitstringOptional

For numeric custom metrics, the unit of measure

eventKeystringOptional

For custom metrics, the event key to use in your code

randomizationUnitslist of stringsOptional

An array of randomization units allowed for this metric

unitAggregationTypeenumOptional
Allowed values: averagesum

The method by which multiple unit event values are aggregated

analysisTypeenumOptional
Allowed values: meanpercentile

The method for analyzing metric events

percentileValueintegerOptional

The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.

eventDefaultobjectOptional
experimentslist of objectsOptional

Experiments that use this metric, including those using a metric group that contains this metric

metricGroupslist of objectsOptional

Metric groups that use this metric

isActivebooleanOptional

Whether the metric is active

_attachedFeatureslist of objectsOptional

Details on the flags attached to this metric

_versionintegerOptional

Version of the metric

selectorstringOptional

For click metrics, the CSS selectors

urlslist of maps from strings to anyOptional

For click and pageview metrics, the target URLs

Errors

Built with