Solved

Exposure tracking through segment

  • 15 May 2023
  • 7 replies
  • 200 views

Badge

Hi there!

For Amplitude experiments, it is recommended to emit an exposure event.
We are using segment.io and are wondering how we can track those events properly.
Whenever we call `track` it ends up being an event with name `$exposure`.

Segment doesn’t seem to wanna pass `event_type` to the destination.

The alternative is to use the `identify` call, but I wonder if there are side effects compared to using the $exposure call.

icon

Best answer by eddie.gaona 16 May 2023, 18:37

View original

7 replies

Userlevel 5
Badge +8

@Florent Vilmart thanks for writing in about this. I’ve shared your question with the technical support team to look into this further.

Userlevel 5
Badge +9

Hello @Florent Vilmart  thank you for reaching out!

 

May I know what the current concerns are with the $Exposure event that is being tracked? What do you mean by “how we can track those events properly”? What is currently not working?

 

If helpful to get you started with Segment and Amplitude Experiment there is a section in the documentation that walks over how to implement with Segment: https://www.docs.developers.amplitude.com/experiment/sdks/javascript-sdk/#integrations

Badge

Hi @eddie.gaona ! Thanks for the quick response! I see that doc now.

This actually works, as long as we provided the payload with flag_key and variant.

Should we only use exposure or can we use `identify(“[Experiment] my_flag”, “variant”)` as well?

Userlevel 5
Badge +9

Hello @Florent Vilmart thank you for reaching back out!

According to the documentation only $Exposure event is needed and Amplitude will fill in the user properties from the Experiment. If you have access to an Experiment playground I would recommend testing this out for yourself.

SegmentExposureTrackingProvider:

class SegmentExposureTrackingProvider implements ExposureTrackingProvider {
private analytics: Analytics;
constructor(analytics: Analytics) {
this.analytics = analytics;
}
track(exposure: Exposure) {
this.analytics.track('$exposure', exposure);
}
}

The Assignment event sets the user properties of the Experiment and then when the Exposure event is triggered the user properties from the Assignment event will carry over.  

Badge

Yes, I’ve tried it and it appears to be working properly. But you can also fill user properties by calling identify. I wonder if the `$exposure` was triggering different mechanisms or if calling

 

 

```identify(userId, { [“[Experiment] my_flag”]: “control” })```

 

is equivalent

Userlevel 5
Badge +9

Hello @Florent Vilmart the recommendation in this case would be to use $exposure. One functionality that I can recall from Experiment is that in order to properly review the data the user needs to have an $Exposure event in their flow. This event tells Amplitude Experiment that the user has been exposed to the Experiment and should be included in the metrics.

 

The $identify call is only for setting user properties. The variant the user gets assigned is already handled by the Assignment event which sets a user property.

Badge

Got it! Thanks for the answer!

Reply