LaunchDarkly
Datafly Signal delivers your server-side events to LaunchDarkly as custom metric events using the metric event import API. This lets conversions, sign-ups, and revenue tracked through Signal power your LaunchDarkly experiments and feature-flag metrics without instrumenting the LaunchDarkly SDK on your servers.
Each Signal event becomes a LaunchDarkly custom event. The event key must match a metric you have already created in LaunchDarkly, and the canonical visitor identifier is sent as the LaunchDarkly user context key so experiment attribution lines up with your flag evaluations.
Prerequisites
- A LaunchDarkly account with Experimentation and at least one custom metric created.
- A personal or service access token with the importEventData permission. Create one under Account settings > Authorization.
- Your LaunchDarkly project key and environment key (for example
defaultandproduction). - One or more custom metrics whose event keys match the events you intend to send (for example
order_completed,sign_up,page_view). Events whose key has no matching metric are accepted but not counted.
Configuration
| Field | Required | Description |
|---|---|---|
| Access Token | Yes | Token with importEventData, sent in the Authorization header (no Bearer prefix). |
| Project Key | Yes | The LaunchDarkly project the events belong to. |
| Environment Key | Yes | The environment the events belong to, e.g. production. |
| Events Host | No | Ingestion host for your cell. Default events.launchdarkly.com; use events.eu.launchdarkly.com (EU) or events.launchdarkly.us (US federal). |
Configure in Signal
- In Signal, open Integrations and add LaunchDarkly.
- Paste your access token and enter the project key and environment key.
- If your account is on the EU or US federal cell, set Events Host accordingly.
- Attach the integration to a pipeline and select the Default preset.
- Confirm that the event keys in the preset (
order_completed,sign_up,page_view, and the funnel events) match the metric event keys in LaunchDarkly. Rename them in the blueprint editor if your metrics use different keys. - Save and enable the pipeline.
API Endpoint
Signal sends a POST request to the server-side metric event import endpoint:
POST https://events.launchdarkly.com/v2/event-data-import/{project_key}/{environment_key}Required headers:
| Header | Value |
|---|---|
Authorization | Your access token (raw, no Bearer prefix) |
Content-Type | application/json |
X-LaunchDarkly-Event-Schema | 4 |
User-Agent | MetricImport-Datafly-int/1.0 |
The request body is a JSON array of custom events. Signal batches events into a single array per request (the body must stay under 10 MB). A successful import returns 202 Accepted.
Identity Signals
LaunchDarkly attributes experiment events using the context key. Signal maps the canonical identifier to contextKeys.user:
user_idis used when the visitor is identified.anonymous_idis used otherwise.
For experiment results to line up, this context key must be the same key your LaunchDarkly SDK uses when it evaluates flags for the user. If your SDK uses a different context kind or key, edit the mapping in the blueprint editor so the keys match.
Event Mapping
The Default preset maps Signal events to LaunchDarkly custom event keys:
| Signal event | LaunchDarkly event key | metricValue |
|---|---|---|
page | page_view | — |
Signed Up | sign_up | — |
Product Viewed | product_viewed | value |
Product Added | add_to_cart | value |
Checkout Started | begin_checkout | value |
Order Completed | order_completed | revenue |
A typical Datafly.js call:
datafly.track("Order Completed", {
order_id: "ORD-1001",
revenue: 89.99,
currency: "GBP"
});Resulting payload delivered to LaunchDarkly:
[
{
"kind": "custom",
"key": "order_completed",
"creationDate": 1749200000000,
"metricValue": 89.99,
"contextKeys": {
"user": "a1b2c3d4-anonymous-id"
},
"data": {
"order_id": "ORD-1001",
"currency": "GBP"
}
}
]For numeric metrics, metricValue carries the revenue or value. Conversion metrics ignore metricValue and simply count the event.
Testing
- Create a custom metric in LaunchDarkly whose event key matches one you are sending (for example
order_completed). - Attach that metric to a running experiment iteration, and make sure the test context has already encountered the experiment.
- Fire the matching event through your site or app.
- In Signal’s Event Debugger, confirm the request to
events.launchdarkly.com/v2/event-data-import/...returned202 Accepted. - In LaunchDarkly, open the experiment’s results. Counted events appear after the next results refresh; they are only counted while the experiment iteration is running.
Troubleshooting
401or403— the access token is invalid or lacks theimportEventDatapermission. Issue a new token with that permission.404— the project key or environment key in the path is wrong. Check them under Account settings.400— malformed payload or an event whosekindis notcustom. Re-check the blueprint mappings.202but no results in LaunchDarkly — the event key does not match any metric, the context never encountered the experiment, or thecreationDatefalls outside the running iteration window. Events outside the iteration window are silently discarded.- Wrong cell — EU or US-federal accounts must set Events Host to
events.eu.launchdarkly.comorevents.launchdarkly.us; sending to the default US host returns404or is dropped.