Audience conditions
This topic describes audience conditions for Optimizely Web Experimentation.
Audiences are defined using logical rules called conditions. Each condition is a rule like "Browser equals Chrome", and an audience is a Boolean combination of these rules, like "Browser equals Chrome OR Referrer matches the substring google.com".
Each individual condition is a JSON object with a type
and other properties depending on that type. You can see how each condition type is defined below, or just create an audience on Optimizely and GET it back to see its condition JSON.
Conditions are joined together in lists. The first element in each list should be "and"
, "or"
, or "not"
, and the rest of the conditions are combined using that operator. You can replace any individual condition with another list, which allows for a nested structure of ANDs and ORs. A "not"
list should only have one condition or list, which are negated. Otherwise, a list with a single condition like ["and", {...}]
will just match that condition.
The full condition object should be passed to the API as a serialized string (for example, by using JSON.stringify(data)
in JavaScript). We will return it in the same format, so to traverse it, you must parse it as an object (with JSON.parse(string)
or equivalent).
For information on Audience Conditions in the Optimizely Web Experimentation, see Audience conditions: Descriptions and examples.
// Condition Grammar: "conditions" should be any value of the form
["and", **]
["or" , **]
["not", *]
"{..}" // an object with keys like ('type', 'value', 'match_type', 'name')
// ** = one or more values from the list above
// * = one value of the form listed above
// Chrome users on SpringSale or FallSale campaign
[
"and",
{
"type": "browser",
"value": "gc"
},
[
"or",
{
"type": "query",
"name": "utm_campaign",
"value": "SpringSale"
},
{
"type": "query",
"name": "utm_campaign",
"value": "FallSale"
},
]
]
// Visitor is not on Firefox
[
"not",
{
"type": "browser",
"value": "ff"
}
]
Ad campaign
- type –
campaign
- match_type – required
- value – optional
Will match if the utm_campaign
query parameter matches value
according to match_type
. If you don't provide a match type, it will default to exact
if a value is provided or exists
if a value is not provided.
Any string value is allowed except:
none
The match_type
can be:
exists
has any valueexact
equalssubstring
containsregex
matches
{
"type": "campaign",
"match_type": "exact",
"value": "campaign_name"
}
For more information about targeting audiences using Ad campaign, see Target audiences using conditions.
Browser or Device (deprecated)
This condition has been replaced by: "Browser / Version", "Device", and "Platform / OS".
- type –
browser
- value – required
For visitors on PC's, this is their browser. For visitors on mobile, this is their device or operating system. Acceptable values are:
mobile
– Any mobile browserandroid
– Android (any browser)blackberry
– Blackberry (any browser)ipad
– iPad (any browser)iphone
– iPhone (any browser)windows phone
– Windows Phone (any browser)ff2
– Firefox 2ff3
– Firefox 3ff4
– Firefox 4ff
– Firefox (any Desktop version)ie6
–Internet Explorer 6(deprecated)ie7
–Internet Explorer 7(deprecated)ie8
– Internet Explorer 8ie9
– Internet Explorer 9ie10
– Internet Explorer 10ie11
– Internet Explorer 11safari3
– Safari 3safari4
– Safari 4safari5
– Safari 5safari6
– Safari 6safari7
– Safari 7safari8
– Safari 8gc
– Google Chromeopera
– Opera
{
"type": "browser",
"value": "ie10"
}
Browser/Version
- type –
browser_version
- value – required
Represents the browser the visitor is using. You may target all browsers in a family (e.g. "safari") or only a specific version, for supported browsers.
Acceptable values are:
ff
– Firefox (any version)ie
– Internet Explorer (any version)ie8
– Internet Explorer 8ie9
– Internet Explorer 9ie10
– Internet Explorer 10ie11
– Internet Explorer 11edge
– Microsoft Edge (any version)safari
– Safari (any version)safari6
– Safari 6safari7
– Safari 7safari8
– Safari 8safari9
– Safari 9safari10
– Safari 10safari11
– Safari 11gc
– Google Chromeopera
– Operaucbrowser
– UC Browser
{
"type": "browser_version",
"value": "ie10"
}
Cookie
- type –
cookies
- name – required
- match_type – required
- value – optional
Will match if cookie name
matches value
according to match_type
. If you don't provide a match type, it will default to exact
if a value is provided or exists
if a value is not provided.
The match_type
can be:
exists
has any valueexact
equalssubstring
containsregex
matches
{
"type": "cookies",
"name": "my_cookie",
"value": "chocolate .*",
"match_type": "regex"
}
Custom Attribute
- type –
custom_attribute
- name – required
- match_type – optional
- value – optional
Will match if the custom_attribute
parameter matches value
according to match_type
. If you don't provide a match type, it will default to exact
if a value is provided or exists
if a value isn't provided.
Note: Full Stack accepts string, number, and boolean values and exists
, exact
, substring
, gt
,
and lt
match types. Web accepts only string values of an exact
match type.
Optimizely Web Experimentation:
{
"type": "custom_attribute",
"name": "Subscriber Status",
"match_type": "exact",
"value": "active",
}
Optimizely Feature Experimentation:
{
"type": "custom_attribute",
"name": "Subscriber ID",
"match_type": "lt",
"value": 9,
}
Device
- type –
device
- value – required
The specific device, or device type, the visitor is using.
Acceptable values are:
iphone
– iPhoneipad
– iPadmobile
– Other mobile phonetablet
– Other tabletdesktop
– Desktop/Laptop
{
"type": "device",
"value": "ipad"
}
Custom Event
- type –
event
- name – required
Will match if the visitor triggered the goal with event name name
.
{
"type": "event",
"name": "event_name"
}
Custom Javascript
- type –
code
- value – required
Will match if the Javascript code in value
evaluates to a truthy value.
{
"type": "code",
"value": "myVariable == true"
}
Custom Tags
- type –
custom_tag
- name – required
- match_type – required
- value – optional
Will match if the custom tag name
matches value
according to match_type
. If you don't provide a match type, it will default to exact
if a value is provided or exists
if a value is not provided.
The match_type
can be:
exists
has any valueexact
equalssubstring
containsregex
matches
{
"type": "custom_tag",
"name": "continent",
"value": "America", // Would match "North America" or "South America"
"match_type": "substring"
}
Dimension
- type –
custom_dimension
- name – required
- value – optional
You can build audiences out of your custom dimension by providing the dimension's name (not ID) in the name
parameter.
{
"type": "custom_dimension",
"name": "whatever",
"value": "1234"
}
IP Address
- type –
ip
- match_type – required
- value – required
Will match if the visitor's IP matches value
according to the match type.
The match_type
can be:
exact
Exact matchregex
Regular expression matchcidr
CIDR Notation (subnet/mask)prefix
Prefix match
{
"type": "ip",
"match_type": "exact",
"value": "1.2.3.4"
}
Language
- type –
language
- value – required
Will match visitors based on their browser's preferred language setting.
Acceptable values are:
ar
– Arabic - anyaf
– Afrikaanssq
– Albanianar-dz
– Arabic - Algeriaar-bh
– Arabic - Bahrainar-eg
– Arabic - Egyptar-iq
– Arabic - Iraqar-jo
– Arabic - Jordanar-kw
– Arabic - Kuwaitar-lb
– Arabic - Lebanonar-ly
– Arabic - Libyaar-ma
– Arabic - Moroccoar-om
– Arabic - Omanar-sa
– Arabic - Saudi Arabiaar-sy
– Arabic - Syriaar-qa
– Arabic - Qatarar-tn
– Arabic - Tunisiaar-ae
– Arabic - U.A.E.ar-ye
– Arabic - Yemeneu
– Basquebe
– Belarusianbg
– Bulgarianca
– Catalanzh
– Chinese - anyzh-hk
– Chinese - Hong Kongzh-cn
– Chinese - PRCzh-sg
– Chinese - Singaporezh-tw
– Chinese - Taiwanhr
– Croatiancs
– Czechda
– Danishnl
– Dutch - anynl-be
– Dutch - Belgianen
– English - anyen-au
– English - Australianen-bz
– English - Belizeen-gb
– English - Britishen-ca
– English - Canadianen-ie
– English - Irelanden-jm
– English - Jamaicaen-nz
– English - New Zealanden-za
– English - South Africaen-tt
– English - Trinidaden-us
– English - United Stateset
– Estonianfa
– Farsifi
– Finnishfr
– French - anyfr-be
– French - Belgianfr-ca
– French - Canadianfr-lu
– French - Luxembourgfr-ch
– French - Swissgd
– Gaelic - anyde
– German - anyde-at
– German - Austriande-li
– German - Liechtensteinde-lu
– German - Luxembourgde-ch
– German - Swissel
– Greekhe
– Hebrewhi
– Hindihu
– Hungarianis
– Icelandicin
– Indonesianit
– Italian - anyit-ch
– Italian - Swissja
– Japaneseko
– Koreanko
– Korean - Johablv
– Latvianlt
– Lithuanianms
– Malaysianmt
– Malteseno
– Norwegianpl
– Polishpt
– Portuguese - anypt-br
– Portuguese - Brazilro
– Romanian - anyro-mo
– Romanian - Moldaviaru
– Russian - anyru-mo
– Russian - Moldaviasr
– Serbiansk
– Slovaksl
– Sloveniansb
– Sorbianes
– Spanish - anyes-ar
– Spanish - Argentinaes-bo
– Spanish - Boliviaes-c
– Spanish - Chilees-co
– Spanish - Colombiaes-cr
– Spanish - Costa Ricaes-do
– Spanish - Dominican Republices-ec
– Spanish - Ecuadores-sv
– Spanish - El Salvadores-gt
– Spanish - Guatemalaes-hn
– Spanish - Hondurases-mx
– Spanish - Mexicanes-ni
– Spanish - Nicaraguaes-pa
– Spanish - Panamaes-py
– Spanish - Paraguayes-pe
– Spanish - Perues-pr
– Spanish - Puerto Ricoes-uy
– Spanish - Uruguayes-ve
– Spanish - Venezuelasx
– Sutusv
– Swedish - anysv-fi
– Swedish - Finlandth
– Thaits
– Tsongatn
– Tswanatr
– Turkishuk
– Ukrainianur
– Urduvi
– Vietnamesexh
– Xhosaji
– Yiddishzu
– Zulu
{
"type": "language",
"value": "af"
}
Location
- type –
location
- value – required
Will geo-target visitors based on their location. Also allows for DMA Regions.
{
"type": "location",
"value": "US|CA|SANFRANCISCO"
}
New/Returning Session
{
"type": "first_session"
}
Platform / OS
- type –
platform
- value – required
Mobile or desktop platform (OS) the visitor is using.
Acceptable values are:
mobile
–Any mobile platform(deprecated)desktop
–Any desktop platform(deprecated)ios
– iOS (any version)ios_6
– iOS 6 (deprecated)ios_7
– iOS 7 (deprecated)ios_8
– iOS 8 (deprecated)ios_9
– iOS 9 (deprecated)ios_10
– iOS 10 (deprecated)ios_11
– iOS 11 (deprecated)android
– Android (any version)android_2.3
– Gingerbread (2.3) (deprecated)android_4.0
– Ice Cream Sandwich (4.0) (deprecated)android_4.1_4.3
– Jellybean (4.1-4.3) (deprecated)android_4.4
– KitKat (4.4) (deprecated)android_5
– Lollipop (5.0) (deprecated)android_6
– Marshmallow (6.0) (deprecated)android_7
– Nougat (7.0) (deprecated)android_8
– Oreo (8.0) (deprecated)windows phone
– Windows Phone (any version)blackberry
– Blackberrywindows
– Windows (any desktop version)windows_7
– Windows 7 (deprecated)windows_8
– Windows 8 (deprecated)windows_8.1
– Windows 8.1 (deprecated)windows_10
– Windows 10 (deprecated)mac os
– OS X (any version)mac os_10.6
– Snow Leopard (10.6) (deprecated)mac os_10.7
– Lion (10.7) (deprecated)mac os_10.8
– Mountain Lion (10.8) (deprecated)mac os_10.9
– Mavericks (10.9) (deprecated)mac os_10.10
– Yosemite (10.10) (deprecated)mac os_10.11
– El Capitan (10.11) (deprecated)mac os_10.12
– Sierra (10.12) (deprecated)mac os_10.13
– High Sierra (10.13) (deprecated)linux
– Linux (any distro)
{
"type": "platform",
"value": "windows"
}
Query Parameters
- type –
query
- name – required
- match_type – required
- value – optional
Will match if the query parameter name
equals value
. according to match_type
. If you don't provide a match type, it will default to exact
if a value is provided or exists
if a value is not provided.
The match_type
can be:
exists
has any valueexact
equalssubstring
containsregex
matches
{
"type": "query",
"name": "my_parameter",
"value": "my_value",
"match_type": "exact"
}
Referrer URL
- type –
referrer
- match_type – required
- value – required
Will match visitors who came from a URL that matches value
according to match_type
.
The match_type
can be:
simple
Simple match (hostname/path only)exact
Exact matchsubstring
Substring matchregex
Regular expression match
{
"type": "source_type",
"value": "referral"
}
Traffic Source
- type –
source_type
- value – required
Acceptable values are:
direct
– Directsearch
– Searchreferral
– Referralcampaign
– Campaign
{
"type": "source_type",
"value": "referral"
}
Time/Day of Visit
- type –
time_and_day
- value – required
Will match visitors who come during certain days of the week, and certain times within those days. The value
takes the form START_END_DAYS
, where the start and end are 24-hour times in the form hh:mm
like 14:30
for 2:30pm. Use 00:00_23:59
to target the full day.
For days, provide a comma separated list of lowercase days of the week like saturday,sunday
. You must provide at least one day.
To target the full week, use monday,tuesday,wednesday,thursday,friday,saturday,sunday
.
Putting this together, to target just weekday mornings, you could provide value: '06:00_11:00_monday,tuesday,wednesday,thursday,friday'
.
{
"type": "time_and_day",
"value": "07:00_11:00_monday,tuesday,wednesday,thursday,friday"
}
Updated 10 months ago