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 for the JavaScript SDK v6+

Describes thetrackEvent method for the JavaScript SDK versions 6 and above, which tracks a conversion event in Optimizely Feature Experimentation

Minimum SDK version

v6.0.0+

For versions 5.3.5 and below, seeJavaScript (Browser) SDK orJavaScript (Node) SDK. See theSDK compatibility matrix documentation for a list of current SDK releases and the features they 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 thetrackEvent method on auserContext. For information about the user object, seeOptimizelyUserContext for the JavaScript SDK v6+.

🚧

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

const attributes = { logged_in: true }; const user = optimizely.createUserContext('user123', attributes); // Map of event propertiesconst properties = {   category: 'shoes',   color: 'red' }; //Map of eventTagsconst tags = {   $opt_event_properties: properties,  revenue: 10000,  value: 100.00}; // user.trackEvent(eventKey (required), eventTags (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 implementation for the JavaScript SDK are available onGitHub.

Updated 17 days ago



[8]ページ先頭

©2009-2025 Movatter.jp