Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
API Reference

Event

Track custom events in Optimizely Web Experimentation.

The event eventName will be tracked and associated with the current visitor.

Syntax

window["optimizely"].push(event);

Parameters

Parameter and TypeChild AttributeDescription
event
EventObject
N/AThis is an event object. Required.
type
string
Child attribute of type EventObjectThis is a static value that indicates that you're using the event function. Required.
eventName
string
Child attribute of type EventObjectThe "API name" for an event created in Optimizely Web Experimentation, e.g., "add_to_cart". Required.
tags
EventTag
Child attribute of type EventObjectA flat object containing metadata about an event (e.g., the SKU of the product being purchased). Some keys are reserved; see the EventTag definition below for the list of such keys.
revenue
integer
Child attribute of type EventTagUsed to submit values for the revenue metric. Values of this tag should be integers equal to 100 times the unit value of the relevant currency (e.g., dollar, euro).

For example, if a conversion results in $75.02 of revenue, then this tag should be included with value 7502.
value
number
Child attribute of type EventTagUsed to submit values for numeric metrics that are not revenue. If it is a number, it is included among both eventMetrics and eventFeatures in the Experimentation Events Export data.

If the value is not a number, this tag is still included among the eventFeatures present in raw data export, but is not among eventMetrics and is not used in computing metric statistics.
_
string or integer
Child attribute of type EventTagYou can specify additional properties of your choice.

Example Call

window["optimizely"].push({
  "type": "event",
  "eventName": "watchedVideo",
  "tags": {
    "title": "Funny Cats",
    "duration": 30,
    "revenue": 5000
  }
});

Description

The event method captures visitor behavior and additional data. You can track clicks and pageviews in Optimizely Web Experimentation without code, but this API call supports tracking other behaviors like watching a video. These events can be used for measuring the results of a campaign or for determining an audience based on behavior.