HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In
Hey! These docs are for version 2.1.0-full-stack, which is no longer officially supported. Click here for the latest version, 1.0!

You can track conversion events from your code with the [Track](🔗) method. This method requires an **event key** and a **user ID**, and also takes optional user **attributes**; see the example below.

The **event key** should match the event key you provided when [creating events](🔗) in the Optimizely app.

The **user ID** should match the ID provided in the [Activate](🔗) or [Is Feature Enabled](🔗) functions. You must pass the same user attributes you used when activating the experiment.

For more information about when and how to track events, see [Event tracking](🔗) and the other topics in this section.

## Usage notes

The [Track](🔗) function can be used to track events across multiple experiments. It will be counted for each experiment only if [Activate](🔗) or [Is Feature Enabled](🔗) has previously been called for the current user.

**Attributes are required for event tracking, not just for segmentation**. Events are only tracked for users who meet the audience conditions of at least one running experiment with a metric defined for the matching event. When users do not meet those conditions, events are not tracked.


**The [Results page](🔗) only shows events that are tracked after [Activate](🔗) or [Is Feature Enabled](🔗) has been called**. If you do not see results on the Results page, make sure that you are activating the experiment or evaluating the feature flag before tracking conversion events.

For information about implementing the User Profile Service purely for tracking purposes and not sticky bucketing, see [Implement a Service](🔗).

## Track events across platforms

For offline event tracking and other advanced use cases, you can also use the [Events API](🔗).

You can use any of our SDKs to track events, so you can run experiments that span multiple applications, services, or devices. All of our SDKs have the same bucketing and targeting behavior, so you'll see the same output from experiment activation and tracking as long as you are using the same datafile and user IDs.

For example, if you're running experiments on your server, you can activate experiments with our Python, Java, Ruby, C#, Node, or PHP SDKs, but track user actions client-side using our JavaScript, Objective-C or Android SDKs.

If you plan to use multiple SDKs for the same project, make sure that all SDKs share the same datafile and user IDs.

For more information, see [Multiple languages](🔗).

Track events

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.