Exposure: {
    experiment_key?: string;
    flag_key: string;
    metadata?: Record<string, unknown>;
    variant?: string;
}

Event object for tracking exposures to Amplitude Experiment.

This object contains all the required information to send an $exposure event through any SDK or CDP to experiment.

The resulting exposure event must follow the following definition:

{
"event_type": "$exposure",
"event_properties": {
"flag_key": "<flagKey>",
"variant": "<variant>",
"experiment_key": "<expKey>"
}
}

Where <flagKey>, <variant>, and <expKey> are the flag_key, variant, and experiment_key variant members on this type:

For example, if you're using Segment for analytics:

analytics.track('$exposure', exposure)

Type declaration

  • Optional experiment_key?: string

    (Optional) The experiment key used to differentiate between multiple experiments associated with the same flag.

  • flag_key: string

    (Required) The key for the flag the user was exposed to.

  • Optional metadata?: Record<string, unknown>

    (Optional) Flag, segment, and variant metadata produced as a result of evaluation for the user. Used for system purposes.

  • Optional variant?: string

    (Optional) The variant the user was exposed to. If null or missing, the event will not be persisted, and will unset the user property.