Experiments let you track how users reacted to the different variations. So, you must tell Optimizely Feature Experimentation which events to track to gauge the relative success of your experiment. After Optimizely Feature Experimentation aggregates enough events to produce meaningful metrics, you can judge your flag variations on the Results page.
You will choose how to aggregate your tracked events into metrics as part of your experimental design process. User events that power metrics are referred to as conversion events. Conversion events can be big or small. You can implement conversion events to capture clicks, pageviews, form submissions, purchases, scroll depth, etc. In general, you want to track events closely associated with user experience with the experimental changes you are making.
At a high level, you will take these steps:
- In the Optimizely app, create an event key string. See Create events.
- Copy the sample integration code for the
Track Eventmethod that Optimizely Feature Experimentation generates.
- Use the
Track Eventmethod to label the event code you want to track. In order for your conversion event to populate experiment metrics on the results page,
Track Eventcode that a user is exposed to if they see a flag variation.
Optimizely recommends getting in the habit of tracking interesting events even if they are not behind feature flags, so you can more easily create future experiments.
Now, every time a user triggers the event, Track Event passes a conversion event to Optimizely Feature Experimentation.
- (Recommended) Filter out third-party bots, so they do not skew your experimental results. For more information, see Filter out bots.
- Add your events to a flag rule. See Run A/B tests and Run flag deliveries.
You can track events server and client-side using one of the Optimizely Feature Experimentation SDKs. You can also track events using our Events API, where you do not have an Optimizely Feature Experimentation SDK implemented. For more information, see Track across platforms.
The results page only shows events that are tracked after a
Decidemethod has been called for the user who triggered the event. If you do not see results on the results page, make sure that you are evaluating the feature flag before tracking conversion events.
The example below shows the
Track Event method called, including optional user attributes.
// Track a conversion event for the provided user with attributes let user = optimizely.createUserContext(userId: "user123", attributes: ["logged_in":true]) // Track a user event try? user.trackEvent(eventKey: "purchased")
For the other SDKs, refer to the reference guide:
- Android SDK
- C# SDK
- Flutter SDK
- Go SDK
- Java SDK
- PHP SDK
- Python SDK
- React SDK
- React Native SDK
- Ruby SDK
- Swift SDK
In circumstances where you cannot install a Feature Experimentation SDK (for example, for offline event tracking and other advanced use cases), you can instead use the Event API.
In circumstances where you can install a Feature Experimentation SDK, you can rest assured that all of our SDK languages have the same audience evaluation and targeting behavior, so you will see the same output from experiment decisions and tracking as long as you are using the same datafile and user contexts. You can use any of our SDKs to track events, so you can run experiments that span multiple applications, services, or devices.
If you plan to use multiple SDKs for the same project, make sure that all SDKs share the same datafile and users.
For more information, see Multiple SDK implementations.
It is possible to track nonbinary metrics on the results page, such as revenue or other numeric values. For information on using reserved event tags to track nonbinary metrics, see Tag events.
After you Create events:
Updated 7 days ago