The Full Stack Developer Guide Developer Hub

Welcome to the Full Stack Developer Guide developer hub. You'll find comprehensive guides and documentation to help you start working with the Full Stack Developer Guide as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Track events

You can track conversion events from your code with the Track method. This method requires:

Track also takes optional user attributes. Optimizely uses attributes passed to Track for segmentation on the Results page. You must pass the user attributes required to meet the audience condition(s) for the experiment(s) in order for the event to be tracked.

As an example, think of an experiment that targets based on location and also passes in device information. That device information could change from event to event, but the location attribute needs to be in there in order to meet the audience condition.

The example below shows Track called with user attributes.

// Track a conversion event for the provided user with attributes
optimizelyClient.track(eventKey, userId, attributes);

// Track a conversion event for the provided user with attributes
OptimizelyClient.Track(eventKey, userId, attributes);

// Track a conversion event for the provided user with attributes
optimizelyClient.track(eventKey, userId, attributes);

// Track a conversion event for the provided user with attributes
optimizelyClient.track(eventKey, userId, attributes);

// Track a conversion event for the provided user with attributes
optimizelyClient.track("my_conversion", userId, {
  plan_type: "silver"
});

// Track a conversion event for the provided user with attributes
[optimizely track:@"my_conversion"
           userId:@"user123"
       attributes:attributes];

// Track a conversion event for the provided user with attributes
$optimizelyClient->track($eventKey, $userId, $attributes);

# Track a conversion event for the provided user with attributes
optimizely_client.track(event_key, user_id, attributes)

# Track a conversion event for the provided user with attributes
optimizely_client.track(event_key, user_id, attributes)

// Track a conversion event for the provided user with attributes
optimizely?.track("my_conversion", userId:"user123", attributes:attributes)

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.

As long as the event key is valid—meaning, the key appears in the datafile—Optimizely will track events. We recommend that you use attributes when you track events for segmentation purposes.

Important

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.

Track events across platforms

For offline event tracking and other advanced use cases, you can also use the Events API.

Important

The Easy Event Tracking functionality included in the Full Stack v3.0 release changes the results of the Optimizely Data Export.

When implementing Full Stack v3.0, you must also upgrade to the Result Exports functionality to obtain reliable event attribution data. For more information, see the Important note in the changelog.

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 audience evaluation 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.