Returns an object exposing the static data fields. These fields are the same for all visitors on all page loads until you modify your project.
Note
optimizely.get("data")
is a performance-intensive operation; as such you should use it sparingly. For example, if you need to get multiple pieces of data in the same function, call it once and reuse that reference:
var data = optimizely.get('data');
var experiment = data.experiments[myExperimentId];
var firstAudience = data.audiences[experiment.audienceIds[0]];
Syntax
data = window["optimizely"].get("data");
Parameters
Parameter | Child Attribute | Description |
---|---|---|
data string | N/A | The argument indicating to get data information. Required. |
Return value
Parameter and Type | Child Attribute | Description |
---|---|---|
StaticData | N/A | The object contains the fields of the objects you've created using the Optimizely UI or REST API. |
audiences object[Audience] | Child attribute of type StaticData | An object mapping an audience ID to an audience. |
conditions array | Child attribute of type Audience | Conditions the visitor must have to be in the audience. |
id string | Child attribute of type Audience | The ID of the audience. |
name string | Child attribute of type Audience | The audience name. |
events object[Event] | Child attribute of type StaticData | An object mapping an event ID to an event. Events determine how/what user behavior is tracked. |
apiName string | Child attribute of type Event | A machine-readable name for the event. The apiName value can be used in the event function to indicate which event has occurred. |
eventType string | Child attribute of type Event | The eventType of the event can be either click or custom to indicate that this event is a Click event or a Custom event. Click events are tied to a specific page and are automatically triggered when a click occurs on the element indicated by the eventFilter.selector value. Custom events need to be manually triggered by executing the event function. |
eventFilter EventFilter or undefined | Child attribute of type Event | A filter that indicates when an event can automatically be triggered. This is currently only set for events with the eventType click . The filter value is undefined for events with the eventType value set to custom . |
filterType string | Child attribute of type EventFilter | The type of filter for an event. Currently the only valid value is target_selector . |
selector string | Child attribute of type EventFilter | A CSS style selector that indicates which element on the page is being tracked. |
id string | Child attribute of type Event | The event ID. |
category string | Child attribute of type Event | An event category that was selected upon creation of the event. Some valid values for category are "added to cart", "saved", "shared", "searched", "purchased", "converted", "signed up", "subscribed", "other". |
name string | Child attribute of type Event | A user-chosen name for an event. |
pageId integer or undefined | Child attribute of type Event | A page ID that indicates the page object this event is related to. This event is only executed on the URLs set in the page object. The pageId field is always undefined for events with the eventType set to custom . |
campaigns *object[Campaign] | Child attribute of type StaticData | An object mapping a campaign ID to a campaign. Campaigns are generated in projects and help tie audiences to experiences. |
changes array[Change] | Child attribute of type Campaign | Changes on a campaign level. These changes are executed every time the campaign gets activated, regardless of the experiment and variation a visitor is assigned to. |
* * | Child attribute of type Change | This object can contain project- or environment-specific properties that are not predefined. |
commitId string | Child attribute of type Campaign | A new "commit" is made every time a campaign is published. The commit ID refers to the commit that was made. Every time a campaign is published, the commit ID changes. |
experiments array[Experiment] | Child attribute of type Campaign | An array of experiments within the campaign. For AB tests, there is always one experiment. Personalization campaigns can have more experiments. |
audienceIds array[string,array] | Child attribute of type Experiment | Representation of audience conditions for the experiment, including audience IDs and combinators. See audience_conditions for format. |
audienceName string | Child attribute of type Experiment | Representation of the name of audience(s) used in the experiment. |
id string | Child attribute of type Experiment | The ID of the experiment. |
name string | Child attribute of type Experiment | The name of the experiment. |
integrationSettings IntegrationObject | Child attribute of type Experiment | An object that contains all the integration settings enabled for this experiment. Each key in the object is mapped to a particular integration. |
* * | Child attribute of type IntegrationObject | This object can contain project- or environment-specific properties that are not predefined. |
variations array[Variation] | Child attribute of type Experiment | The variations within an experiment. There are one or more variations in an experiment. |
actions Action | Child attribute of type Variation | The actions that are executed once a visitor gets bucketed in this variation. The actions describe the variation. |
pageId string | Child attribute of type Action | The ID of the page where the action will take place. |
changes array[Change] | Child attribute of type Action | An array of changes that have been set up for this page. |
* * | Child attribute of type Change | This object can contain project- or environment-specific properties that are not predefined. |
id string | Child attribute of type Variation | The ID of the variation. |
name string | Child attribute of type Variation | The name of the variation. |
weightDistributions null or array[WeightDistributionsObject] | Child attribute of type StaticData | Traffic allocation among the variations in the experiment. |
entityId string | Child attribute of type WeightDistributionsObject | The ID of the variation that has the endOfRange value assigned to it. |
endOfRange integer | Child attribute of type WeightDistributionsObject | Each object in the array has a endOfRange value. The endOfRange of the current object minus the endOfRange object of the previous object is the traffic allocation assigned to the variation. The last object in the array always has a endOfRange value of 10000. |
id string | Child attribute of type Campaign | The ID of the campaign. |
name string | Child attribute of type Campaign | The name of the campaign. |
holdback integer | Child attribute of type Campaign | The holdback value on a campaign represents the percentage of visitors excluded from a campaign. If the holdback is set to 500, then 5% of all visitors are excluded from the campaign. |
policy string | Child attribute of type Campaign | The policy of a campaign indicates whether the campaign is an AB test or a Personalization campaign. The possible values are:single_experiment : A normal AB testrandom : A Personalization campaign |
integrationSettings IntegrationObject | Child attribute of type Campaign | An object that contains all the integration settings enabled for this campaign. |
* * | Child attribute of type IntegrationObject | This object can contain project- or environment-specific properties that are not predefined. |
pageIds array[string] | Child attribute of type Campaign | An array with the IDs of all the pages that are used within the campaign. |
pages object[Page] | Child attribute of type StaticData | An object mapping of a page ID to a page. Pages are used to determine where experiments will execute and to track user behavior. |
apiName string | Child attribute of type Page | A machine-readable name for the page. The apiName value can be used in the page function to indicate which event has occurred. |
id string | Child attribute of type Page | The page ID. |
category string | Child attribute of type Page | An event category that was selected upon creation of the page. Some valid values for the category are "added to cart", "saved", "shared", "searched", "purchased", "converted", "signed up", "subscribed", "other". |
staticConditions array | Child attribute of type Page | A user-chosen name for a page. |
tags array[VisualTagObject] | Child attribute of type Page | An array of the visual tags saved on a page. Read more about visual tags. |
category string | Child attribute of type VisualTagObject | A tag category that was selected upon creation of the tag. Some valid values for the category are "category", "subcategory", "title", "price", "other". |
locator string | Child attribute of type VisualTagObject | The logic/CSS selector indicating where a tag is located on the page. |
apiName string | Child attribute of type VisualTagObject | A machine-readable name for the tag. |
locatorType string | Child attribute of type VisualTagObject | A enum that indicates if the locator is custom "javascript" or a "css_selector". |
experiments object[Experiment] | Child attribute of type StaticData | An object mapping of an experiment ID to an experiment. Every campaign has one or more experiments. |
audienceIds array[string,array] | Child attribute of type Experiment | Representation of audience conditions for the experiment, including audience IDs and combinators. See audience_conditions for format. |
audienceName string | Child attribute of type Experiment | Representation of name of audience(s) used in the experiment. |
id string | Child attribute of type Experiment | The ID of the experiment. |
name string | Child attribute of type Experiment | The name of the experiment. |
integrationSettings IntegrationObject | Child attribute of type Experiment | An object that contains all the integration settings that are enabled for this experiment. Each key in the object is mapped to a particular integration. |
* * | Child attribute of type IntegrationObject | This object can contain project- or environment-specific properties that are not predefined. |
variations array[Variation]** | Child attribute of type Experiment | The variations within an experiment. There are one or more variations in an experiment. |
actions Action | Child attribute of type Variation | The actions that are executed once a visitor gets bucketed in this variation. The actions describe the variation. |
pageId string | Child attribute of type Action | The ID of the page where the action will take place. |
changes array[Change] or string | Child attribute of type Action | An array of changes that have been set up for this page. |
* * | Child attribute of type Change | This object can contain project- pr environment-specific properties that are not predefined. |
id string | Child attribute of type Variation | The ID of the variation. |
name string | Child attribute of type Variation | The name of the variation. |
weightDistributions null or array[WeightDistributionsObject] | Child attribute of type StaticData | Traffic allocation among the variations in the experiment. |
entityId string | Child attribute of type WeightDistributionsObject | The ID of the variation that has the endOfRange value assigned to it. |
endOfRange string | Child attribute of type WeightDistributionsObject | Each object in the array has a endOfRange value. The endOfRange of the current object minus the endOfRange object of the previous object is the traffic allocation assigned to the variation. The last object in the array always has a endOfRange value of 10000. |
variations object[Variation] | Child attribute of type StaticData | An object mapping of a variation ID to a variation. The variations are used in experiments and experiences. |
actions Action | Child attribute of type Variation | The actions that are executed once a visitor gets bucketed in this variation. The actions describe the variation. |
pageId string | Child attribute of type Action | The ID of the page where the action will take place. |
changes array[Change] or string | Child attribute of type Variation | An array of changes that have been set up for this page. |
* * | Child attribute of type Change | This object can contain project- or environment-specific properties that are not predefined. |
id string | Child attribute of type Variation | The ID of the variation. |
name string | Child attribute of type Variation | The name of the variation. |
projectId string | Child attribute of type StaticData | The ID of your Optimizely Web Experimentation project that is installed on this page. |
accountId string | Child attribute of type StaticData | The ID of your Optimizely Web Experimentation account. |
dcpServiceId string or null | Child attribute of type StaticData | The ID of a DCP service associated to the project installed on this page. |
revision string | Child attribute of type StaticData | The revision of your snippet. The revision is incremented every time the snippet is updated. |
Example Call
data = window["optimizely"].get("data");
Example Return Value
{
"audiences": {
"4728608810": {
"conditions": ["and", ["or", ["or", {
"value": "search",
"type": "source_type",
"name": null,
"match": null
}, {
"value": "campaign",
"type": "source_type",
"name": null,
"match": null
}]]],
"id": "6618392098",
"name": "Search traffic"
}
},
"events": {
"4958230289": {
"category": "other",
"name": null,
"eventType": "click",
"apiName": "blog_clicks_hero_nav",
"id": "4958230289",
"eventFilter": {
"filterType": ".hero-container",
"selector": "target_selector"
},
"pageId": "4761512980"
}
},
"campaign": {
"6676370413": {
"holdback": 500,
"activation": {},
"integrationSettings": {},
"viewIds": ["6678290257"],
"experiments": [{
"weightDistributions": null,
"audienceName": "Chrome users",
"name": null,
"bucketingStrategy": null,
"variations": [{
"id": "6626731852",
"actions": [],
"name": "Variation #1"
}],
"audienceIds": ["6672770135"],
"changes": null,
"id": "6666781105",
"integrationSettings": null
}],
"id": "6676370413",
"weightDistributions": null,
"name": "Example personalization campaign",
"commitId": "6667420425",
"decisionMetadata": null,
"policy": "ordered",
"changes": null,
"pageIds": ["6678290257"]
}
},
"pages": {
"6678290257": {
"category": "other",
"staticConditions": ["and", ["or", {
"type": "url",
"value": "https://developers.optimizely.com/",
"match": "simple"
}]],
"name": "Homepage",
"tags": [{
"category": "other",
"locator": ".push-quad > a:nth-of-type(1)",
"valueType": "string",
"locatorType": "css_selector",
"apiName": "view_docs_button"
}],
"apiName": "homepage",
"id": "6678290257"
}
},
"experiments": {
"6661191859": {
"weightDistributions": [{
"entityId": "6665951608",
"endOfRange": 5000
}, {
"entityId": "6670551924",
"endOfRange": 10000
}],
"audienceName": "Everyone else",
"name": null,
"bucketingStrategy": null,
"variations": [{
"id": "6665951608",
"actions": [],
"name": "Original"
}, {
"id": "6670551924",
"actions": [{
"viewId": "6678290257",
"changes": [{
"selector": ".flex-justified--center > div:nth-of-type(1) .push-double--top",
"dependencies": [],
"attributes": {
"html": "Web "
},
"type": "attribute",
"id": "4810EE32-D209-4EBD-A8DC-6CE245DA8B6B",
"css": {}
}],
"pageId": "6678290257"
}],
"name": "Variation #1"
}],
"audienceIds": null,
"changes": null,
"id": "6661191859",
"integrationSettings": null
}
},
"variations": {
"7600254716": {
"id": "7600254716",
"actions": [{
"viewId": "7585662249",
"changes": [{
"selector": "h1",
"dependencies": [],
"attributes": {
"html": "Develop with Optimizely! "
},
"type": "attribute",
"id": "EE809A94-4044-4DD0-B387-D05D478ED702",
"css": {}
}],
"pageId": "7585662249"
}],
"name": "Variation #1"
}
},
"projectId": "6663270427",
"accountId": "200607994",
"revision": "2433",
"dcpServiceId": "3383760141"
}
Description
A function to get the data
object. The data
object contains the fields of the objects you've created using the Optimizely UI or REST API. For example, if you create a new experiment using an audience, page and event, then you can expect to find all of those objects in the data
object that's returned from this function.