HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Visitor

Optimizely Web Experimentation uses visitor attributes for targeting and segmentation. The visitor object contains all the attributes that can be used for targeting and segmentation.

Syntax

visitor = window["optimizely"].get("visitor");

Parameters

Parameter and TypeChild AttributeDescription
visitor
string
N/AThe argument indicating to get visitor information. Required.

Return value

Parameter and TypeChild AttributeDescription
VisitorDataN/AThe object contains all the attributes that can be used for targeting and segmentation.
browserId
string
Child attribute of type VisitorDataA unique identifier for the browser type.
browserVersion
string
Child attribute of type VisitorDataThe version of the browser.
source_type
string
Child attribute of type VisitorDataOptimizely Web Experimentation evaluates how a visitor came to the website based on the referrer value. Possible values are direct, search, and referral.
visitorId
string
Child attribute of type VisitorDataA unique ID that Optimizely Web Experimentation uses to identify a visitor.
custom
object[CustomAttributeObject]
Child attribute of type VisitorDataAn object whose keys are custom attribute IDs and whose values are CustomAttributeObjects. Contains values for all custom attributes that have been set for the visitor.
id
string
Child attribute of type CustomAttributeObjectThe ID of the custom attribute, as displayed in the Audiences > Attributes dashboard.
value
string
Child attribute of type CustomAttributeObjecThe value of the custom attribute as set for the current visitor.
*
*
Child attribute of type VisitorDataThis object can contain project- or environment-specific properties that are not predefined.

Example Call

visitor = window["optimizely"].get("visitor");

Example Return Value

{
  "browserId": "gc",
  "browserVersion": "53.0.2785.143",
  "source_type": "referral",
  "visitorId": "oeu1476217818972r0.36434468013549726",
  "custom": {
    "7973492630": {
      "id": "7973492630",
      "value": "High Tech"
    },
    "7995780411": {
      "id": "7995780411",
      "value": "commercial 1"
    }
  }
}