Track user events
Explains events in Optimizely Feature Experimentation, which let you to track the success of your experiments.
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 Optimizely Experiment Results page.
You choose how to turn 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, page views, form submissions, purchases, scroll depth, and so on. In general, you want to track events closely associated with the user experience your experiments are updating.
Note
You develop the practice of tracking interesting events, even if they are not behind a flag, so you can create future experiments quickly.
Event properties
Beta
Event properties are currently in beta. Contact your Customer Success Manager or sign up for the beta on Optimizely.com.
Event properties let you filter a created event down in Optimizely’s UI based on additional information you have attached to that event. When you send events, you can add information about the product or action performed to create a more specific metric when using the event in the experiment results.
During the beta period, Optimizely Feature Experimentation currently supports event properties as a nested object within event tags. When you call the Track Event
method, you can include event tags as an optional key-value argument. To send event properties, the reserved naming of $opt_event_properties
must be applied when nested into the tags object.
See the links in the Example code section to see how to implement event properties in the Track event
method. See the Create events documentation for information on setting up event properties. See Create a metric in Optimizely using the metric builder for information on adding event properties to metrics.
Setup overview
At a high level, you will take these steps:
- In the Optimizely app, create an event and a unique key string that you will reference in your code when you call
Track Event
. See Create events. - Copy the sample integration code for the
Track Event
method that Optimizely Feature Experimentation generates in the UI. - Use the
Track Event
method to label the event code you want to track. To ensure your conversion event populates the metrics on the Experiment Results page, implement theTrack Event
code when users are exposed to a flag variation. - (Recommended) Filter out third-party bots so they do not skew your experimental results. For information, see Filter out bots.
- Add your events to a flag rule as metrics. 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 or Optimizely Agent. You can also track events using the Events API, where you do not have an Optimizely Feature Experimentation SDK implemented. For information, see Track across platforms.
Important
The Experiemnt Results page only shows tracked events after a
Decide
method is called for the user who triggered the event.If you do not see results on the results page, ensure you are evaluating the feature flag before tracking conversion events.
Example code
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
- JavaScript (Browser) SDK
- JavaScript (Node) SDK
- PHP SDK
- Python SDK
- React SDK
- React Native SDK
- Ruby SDK
- Swift SDK
For Optimizely Agent, see Use Optimizely Agent.
Track events across platforms
If you cannot install a Feature Experimentation SDK, for example, for offline event tracking or other advanced use cases:
If you can install a Feature Experimentation SDK:
- All SDK languages have consistent audience evaluation and targeting behavior.
- You can use the same datafile and user contexts to achieve the same output from experiment decisions and tracking.
- Use any Feature Experimentation SDK to track events and run experiments across multiple applications, services, or devices.
For example, you can make the experiment decisions using a server-side SDK (Python, Java, Ruby, C#, Node, or PHP SDKs) but track user actions using a client-side SDK (including JavaScript, React, iOS, or Android SDKs). If you plan to use multiple SDKs for the same project, ensure that the SDKs share the same datafile and users. For information, see Multiple SDK implementations.
Note
You can also use cross-project events to track events across your Optimizely Web Experimentation and Optimizely Feature Experimentation projects.
Track numeric metrics
On the Experiment Results page, you can track nonbinary metrics such as revenue or other numeric values. For information on using reserved event tags to track nonbinary metrics, see Tag events.
Next Steps
After you Create events:
- Add events to an experiment flag rule. See Run A/B tests or Run a multi-armed bandit optimization.
- Decide how events are displayed on the Experiment Results page as metrics. See Choose metrics.
More information
For information on how Optimizely Experimentation handles events, see Events: Track clicks, page views, and other visitor actions.
Also, see how Optimizely Experimentation attributes a single user's events over time.
Updated about 2 months ago