About this piece: This piece explains how SDKs record and categorize user interactions within an app.
I worked with LaunchDarkly’s SDK team to rewrite and expand on a significantly shorter version of this content. I wrote it in Markdown using VS Code, then submitted the file to GitHub for review by another technical writer on my team.
Experimentation and metric events
This topic explains how LaunchDarkly SDKs handle experimentation and metric events.
An “event” happens when someone takes an action in your app, such as clicking on a button, or when a system takes an action, such as loading a page. Your SDKs send these events to LaunchDarkly, which aggregates and analyzes them.
There are two kinds of events associated with experiments and metrics:
- Evaluation events: your SDKs send
featureevaluation events to LaunchDarkly when they evaluate a flag for a context and emit a feature event, for example, by calling a variation method. When that flag is part of a running experiment, LaunchDarkly assigns the context to the experiment audience and records exposures. - Metric events: your SDKs send
click,page view, andcustommetric events to LaunchDarkly when an end user or other context interacts with a part of your app you’re tracking with a metric. To learn more, read Events.
Here are examples of each event kind:
Clicked or tapped metric event
{
"kind": "click",
"key": "<internal id, not used>",
"url": "https://example.com/",
"creationDate": 16420388151234,
"selector": "button.click-track",
"contextKeys": {
"user": "Sandy",
"anonymousUser": "123213421231"
}
}
Custom conversion metric event
{
"kind": "custom",
"key": "example-event-key",
"creationDate": 16420388151234,
"contextKeys": {
"user": "Sandy",
"anonymousUser": "123213421231"
}
}
Feature evaluation event
{
"kind": "feature",
"creationDate": 1462220944000,
"key": "example-flag-key",
"variation": 0,
"variationName": "my variation",
"value": false,
"default": false,
"version": 42,
"reason": {
"inExperiment": "true"
},
"prereqOf": "example-prereq-flag-key",
"contextKeys": {
"user": "sandy",
"anonymousUser": "123213421231"
}
}
The SDK track method
Server-side, client-side, and mobile LaunchDarkly SDKs send custom metric events when you call the SDK’s track method.
In addition, the JavaScript SDK also sends a click metric event when an end user clicks or taps on a page URL or anchor tag that you have included in a clicked or tapped metric, and sends a page view metric event when an end user visits a URL that you have included in a page viewed metric.
To learn how to view a list of all of the metric events your SDKs are sending to LaunchDarkly, read Viewing incoming events. This list shows a historical view of all events received over the last 90 days and is useful for choosing the right events to use in your metrics.
You can also view metric events on the Live events page using the Experiments filter. The Live events page displays events as they arrive in real time, and can act as live debugging tool while you develop your event tracking code.
If you prefer to import metric events from your existing data pipeline, read Importing metric events.
Evaluation events
Server-side, client-side, and mobile LaunchDarkly SDKs send a feature event when you call the SDK’s variation method to evaluate a flag in an experiment.
The JavaScript SDK and most JavaScript-based SDKs also send a feature event when you call the SDK’s allFlags method, unless you configure it not to. The exception to this is the React Web SDK, which does not send an event by default when you call the allFlags method. To learn more about events in the React Web SDK, read Events.
Configuring the JavaScript SDK and JavaScript-based SDKs not to send feature events when you call allFlags limits the number of events these SDKs send to LaunchDarkly. To learn more about how SDKs send events, read Analytics events.