Target on User Attributes
Setup an Audience based on User/Browser/OS Attributes
Using ABlyft to target the properties of the user, the browser or the operating system used is very easy and very flexible possible.
A JavaScript object is provided which allows to use these properties.
On this page
Introduction
Basic Targeting
For example, to target users who use a desktop browser, the following can be done:
if(User.browser.desktop){
return true;
}
If you, for example, want to target on Firefox users using it on macOS:
if(User.browser.firefox && User.browser.mac){
return true;
}
More advanced Targeting
If you want to specifically target only the cases checked by the quality assurance, it can be helpful to only allow browsers from a certain version to participate in the test.
//Target on Internet Explorer with Version from 9 and up
if(User.browser.msie && User.browser.version >= 9){
return true;
}
Documentation
Device flags
If detected, one of these flags may be set to true
:
mobile | All detected mobile OSes are additionally flagged mobile, unless it's a tablet |
tablet | If a tablet device is detected, the flag tablet is set instead of mobile |
desktop | If it is neither a mobile nor a tablet |
//Only target mobile Devices (not Tablets)
if(User.browser.mobile){
return true;
}
Browser flags
If detected, one of these flags may be set to true. The rendering engine flag is shown in []:
- msedge
- opera
- samsungBrowser
- firefox
- chromium
- chrome
- msie
- safari
For all detected browsers the browser version is set in the version
field.
OS Flags
If detected, one of these flags may be set to true
:
- windows
- mac
- android
- ios
- linux
osversion
may also be set:
-
osversion
- for Android, iOS, MacOS, Windows, Windows Phone, WebOS, Bada, and Tizen. If included in UA string.
iOS is always reported as ios and additionally as iphone/ipad/ipod
, whichever one matches best.
//Only Target on Tablets based on iOS (newer than 9) or Android
if(User.browser.tablet){
if((User.browser.ios && User.browser.osversion > 9) || User.browser.android){
return true;
}
}