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 default and production).
  • 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

FieldRequiredDescription
Access TokenYesToken with importEventData, sent in the Authorization header (no Bearer prefix).
Project KeyYesThe LaunchDarkly project the events belong to.
Environment KeyYesThe environment the events belong to, e.g. production.
Events HostNoIngestion host for your cell. Default events.launchdarkly.com; use events.eu.launchdarkly.com (EU) or events.launchdarkly.us (US federal).

Configure in Signal

  1. In Signal, open Integrations and add LaunchDarkly.
  2. Paste your access token and enter the project key and environment key.
  3. If your account is on the EU or US federal cell, set Events Host accordingly.
  4. Attach the integration to a pipeline and select the Default preset.
  5. 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.
  6. 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:

HeaderValue
AuthorizationYour access token (raw, no Bearer prefix)
Content-Typeapplication/json
X-LaunchDarkly-Event-Schema4
User-AgentMetricImport-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_id is used when the visitor is identified.
  • anonymous_id is 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 eventLaunchDarkly event keymetricValue
pagepage_view
Signed Upsign_up
Product Viewedproduct_viewedvalue
Product Addedadd_to_cartvalue
Checkout Startedbegin_checkoutvalue
Order Completedorder_completedrevenue

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

  1. Create a custom metric in LaunchDarkly whose event key matches one you are sending (for example order_completed).
  2. Attach that metric to a running experiment iteration, and make sure the test context has already encountered the experiment.
  3. Fire the matching event through your site or app.
  4. In Signal’s Event Debugger, confirm the request to events.launchdarkly.com/v2/event-data-import/... returned 202 Accepted.
  5. 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

  • 401 or 403 — the access token is invalid or lacks the importEventData permission. 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 whose kind is not custom. Re-check the blueprint mappings.
  • 202 but no results in LaunchDarkly — the event key does not match any metric, the context never encountered the experiment, or the creationDate falls 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.com or events.launchdarkly.us; sending to the default US host returns 404 or is dropped.