Dev guideAPI Reference
Dev guideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Track event method for the Flutter SDK

Describes the track event method, which tracks a conversion event in Optimizely Feature Experimentation.

Tracks a conversion event or action for a user. Logs an error message if the specified event key does not match any existing events.


1.0.1 or higher


Use this method to track events across multiple flag rules for a user. You should only make one track call per conversion (user action), even if many rules measure the conversion.

You call the Track Event method on a user. For more information about the user object, see OptimizelyUserContext.

The attributes passed to Track Event are only used for results segmentation.


This table lists the required and optional parameters for the Track Event method.

StringThe key of the event to be tracked. This key must match the event key provided when you created the event in the Optimizely app.
MapA map of key-value pairs specifying tag names and their corresponding tag values for this particular event occurrence. Values can be strings, numbers or booleans.

Used to track numeric metrics, allowing you to track actions beyond conversions, for example revenue, load time or total value. See details on reserved tag keys.


This method sends conversion data to Optimizely Feature Experimentation. It does not provide return values.


var attributes = <String, dynamic>{};
attributes["logged_in"] = true;
var user = await flutterSDK.createUserContext(userId: "user123", attributes: attributes);

var tags = <String, dynamic>{};
tags["category"] = "shoes";
tags["purchase_count"] = 2;

await user!.trackEvent("my_purchase_event_key", tags);

Side effects

The table lists other Optimizely Feature Experimentation functionality using this method may trigger.

ConversionsCalling this method records a conversion and attributes it to the variations the user saw.

You can create metrics on this conversion event and add metrics to experiments, even after the system tracked the conversion.

For more information, see the support documentation on Event Tracking.


- This method will not track events when the specified event key is invalid.
- Changing the traffic allocation of running experiments affects how the system records conversions and attributes variations to users.
Notification ListenersAccessing this method triggers a call to the TRACK notification listener.


This method will not call the TRACK notification listener when the specified event key is invalid.

Source files

The language/platform source files containing the implementation for Flutter Android is at and for Flutter iOS is at OptimizelyClient.swift.