Movatterモバイル変換


[0]ホーム

URL:


Dev guideRecipesAPI ReferenceChangelog
Dev guideAPI ReferenceRecipesChangelogUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog InFeature Experimentation
Dev guide
All
Pages
Start typing to search…

Track event method for the Java SDK

Describes thetrackEvent method for the Java SDK, which tracks a conversion event in Optimizely Feature Experimentation.

Version

SDK 3.8 and higher. SeeMinimum version support.

Description

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

You call the Track Event method on a user. For information about the user object, seeOptimizelyUserContext for the Java SDK.

🚧

Important

The attributes passed totrackEvent areonly used forresults segmentation on theOptimizely Experiment Results page.

Parameters

  • eventKey (required) – String – The key of the event to be tracked. This key must match the event key provided when the event was created inthe Optimizely app orREST API.
  • eventTags (optional) – Map – A map of key-value pairs specifying thereserved tag keys names and their corresponding values for this particular event occurrence.eventTags are contextual metadata aboutconversion events. For example, revenue, load time, or total value. The following are available tag keys:
    • revenue – An integer value that is used to track the revenue metric for your experiments, aggregated across all conversion events.revenue is recorded in cents.
    • value – A floating point value that is used to track a custom value for your experiments. Use this to pass the value for numeric metrics.
    • $opt_event_properties – A map of default and custom event properties and their values.

Seereserved event tags.

Returns

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

Example

Map<String, Object> attributes = new HashMap<>(); attributes.put("logged_in", true); OptimizelyUserContext user = optimizely.createUserContext("user123", attributes); //Map of event propertiesMap<String, Object> properties = new HashMap<>();properties.put("category", "shoes");properties.put("color", "red");// Map of eventTagsMap<String, Object> tags = new HashMap<>(); tags.put("revenue", 10000); tags.put("value", 100.00); tags.put("$opt_event_properties", properties);//user.trackevent(eventKey (required), eventTag (optional))user.trackEvent("my_purchase_event_key", tags);

Side effects

Additional Feature Experimentation functionality may be triggered by using this method.

Conversions

Calling this method records a conversion and attributes it to the variations that the user has seen. SeeHow Optimizely Experimentation counts conversions.

You can createmetrics on this conversion event and add metrics to experiments even after the conversion is tracked. SeeEvents: Tracking clicks, pageviews, and other visitor actions.

❗️

Warning

This method does not track events if the event key is invalid.

Changing the traffic allocation of running experiments affects how conversions are recorded and variations are attributed to users. SeeWhy you should not change a running experiment.

Notification listeners

Accessing this method triggers a call to thetrack notification listener.

❗️

Warning

This method does not call theTRACK notification listener if the event key is invalid.

Source files

The language and platform source files containing the Java implementation are available onGitHub.

Updated 17 days ago



[8]ページ先頭

©2009-2025 Movatter.jp