On this page

Exposure tracking in Amplitude Experiment

When running an experiment, track each user's exposure to your feature flag's variant experience. Without exposure tracking, results aren't reliable.

Exposure tracking is optional for feature flags that don't require analysis.

Analytics REST API

In this example, the Analytics REST API v2.0 sends an exposure event to Amplitude with curl.

Exposure example

POST · /2/httpapiHTTP V2 API
Request parameters
Find it in Settings → Projects. 32-character hex string.
Not sent
cURLPOST · /2/httpapi
curl --request POST \
--url 'https://api2.amplitude.com/2/httpapi' \
--data '{"api_key":"","events":[{"event_type":"$exposure","user_id":"","event_properties":{"flag_key":"","variant":""}}]}'
$ awaiting send…

When the request succeeds, a user appears in the Exposures chart in Amplitude Experiment.

The flag is now active in your deployment, and your experiment evaluated a user and served them the variant.

SDKs

As with fetching variants, you can simplify exposure tracking using a client-side Experiment SDK in your app. Client-side Amplitude Experiment SDKs automatically track exposures through your installed analytics SDK whenever the Experiment SDK accesses a variant from the variant store.

Was this helpful?