Skip to content

Exposure Tracking

An exposure event is a strictly defined analytics event sent to Amplitude in order to inform Amplitude Experiment that a user has been exposed to a certain variant of an experiment or feature flag. Exposure events contain the flag key and the variant of the flag or experiment that the user has been exposed to in the event's event properties.

When an exposure event is ingested by Amplitude, the flag key and variant are used to set or unset user properties on the user associated with the event. Setting user properties is essential for experiment analysis queries on primary and secondary success metrics.

Event Volume

Amplitude defined exposure events do not count toward your organization's event volume billing.

Automatic exposure tracking

Client-side Experiment SDKs above a certain version support automatic exposure tracking through an exposure tracking provider, often implemented through an analytics SDK integration.

Integrations

Client-side sdks currently support two integrations, Amplitude and Segment (you may also implement your own custom integration).

SDK
Version
JavaScript SDK 1.4.1+
Android SDK 1.5.1+
iOS SDK 1.6.0+
React Native 0.6.0+

Exposure event

The exposure event has been designed to be simple and ergonomic enough to be sent through any analytics implementation or customer data platform without needing to manipulate user properties directly. When an $exposure event is ingested, the requisite user properties are automatically set or unset for 100% accuracy and confidence.

Definition

Event Type
Event Property
Requirement Description
$exposure flag_key Required The flag or experiment key which the user is being exposed to.
variant Optional The variant for the flag or experiment that the user has been exposed to. If null or missing, the user property for the flag/experiment is unset, meaning that the user no longer is considered to be a part of the experiment.

Example

Potential data changes

This example makes real requests to the API and can potentially change the data in your Amplitude project. We recommend using a development project when testing APIs.

curl --request POST \
     --url https://api2.amplitude.com/2/httpapi \
     --data '{"api_key":"","events":[{"event_type":"$exposure","user_id":"","device_id":"","event_properties":{"flag_key":"","variant":""}}]}'

Variable
Description
The analytics API key from project which you created your flag and deployment in.
The user's ID.
The user's device ID.
The flag key of the flag or experiment the user has been exposed to.
The variant key (e.g. on, control, treatment).
Track Exposure

Result:




Last update: 2022-06-21