Properties
In Optimizely Web Experimentation, all of the properties are accessible through functions. From a performance point of view, this is a huge improvement, but it does change the structure of how data is accessible. Below is an overview of how to access data that you had access to in Classic with the Optimizely Web Experimentation JavaScript API.
If the Optimizely snippet is in a bundled state, you can access all your Classic data through the Classic JS API and Optimizely Web Experimentation data through the Optimizely X JS API.
State
Available in Optimizely Web Experimentation: Yes, but in a different format.
Classic format:
window["optimizely"].data.state
Optimizely Web Experimentation format:
window["optimizely"].get("state")
The state object contains information about the current state of Optimizely on the page. In Optimizely Classic, the state object contained properties containing information about which experiments were active, which variations a visitor saw at the moment, and whether a redirect experiment had executed on the previous page. All that information is accessible in Optimizely Web Experimentation with the window["optimizely"].get("state")
function. In Optimizely Classic the state object contained function instead of properties. With the functions that are returned, you can specify filters. All the same information is available through those methods.
Read more about the available methods here.
Visitor
_Available in Optimizely Web Experimentation: Yes, but in a different format.
Classic format:
window["optimizely"].data.visitor
Optimizely Web Experimentation format:
window["optimizely"].get("visitor")
The visitor object contains information about what Optimizely knows about the current visitor. In Optimizely Web Experimentation, that same information (and more) is accessible through the window["optimizely"].get("visitor")
function.
Read more about the visitor object here.
Data
_Available in Optimizely Web Experimentation: Yes, but in a different format.
Classic format:
window["optimizely"].data
Optimizely Web Experimentation format:
window["optimizely"].get("data")
The data object in Optimizely Classic contained all the information that you could read. In Optimizely Classic state data and visitor information were nested in the data object. In Optimizely Web Experimentation, they are separated into new functions (see above). All the static data that used to be in window["optimizely"].data
is accessible with window["optimizely"].get("data")
. The returned object contains information about all the campaigns, experiments, audiences, pages, and events published in your Optimizely project.
Read all about the new data object here.
Revision
_Available in Optimizely Web Experimentation: Yes, but in a different format.
Classic format:
window["optimizely"].revision
Optimizely Web Experimentation format:
window["optimizely"].get("data").revision
The revision number is accessible through window["optimizely"].get("data").revision
.
Get account ID
_Available in Optimizely Web Experimentation: Yes, but in a different format.
Classic format:
window["optimizely"].getAccountId()
Optimizely Web Experimentation format:
window["optimizely"].get("data").accountId
In Optimizely Web Experimentation, the account ID is stored in the data Object. You can access the account ID with window["optimizely"].get("data").accountId
.
Get project ID
_Available in Optimizely Web Experimentation: Yes, but in a different format.
Classic format:
window["optimizely"].getProjectId()
Optimizely Web Experimentation format:
window["optimizely"].get("data").projectId
In Optimizely Web Experimentation, the project ID is stored in the data Object. You can access the project ID with window["optimizely"].get("data").projectId
.
Updated over 1 year ago