Scriptlet: Smartphone Sensing

This script may be copied into your Ion Server Scriptlet library and then used as a custom Ion advanced rule condition.

// return "true" if respondent is on a mobile device
// save name of mobile device in "MobileDevice" data field
// reference: http://www.zytrax.com/tech/web/mobile%5Fids.html

if (!respondent.useragent) {
return "false"; // if no user agent string, return "false"
}
var ua = respondent.useragent; // shortcut

if (ua.indexOf("iPhone") != -1) {
actionAssignTag("mobile");
actionSaveData("MobileDevice", "iPhone");
return "true";
}
if (ua.indexOf("BlackBerry") != -1) {
actionAssignTag("mobile");
actionSaveData("MobileDevice", "Blackberry");
return "true";
}
if (ua.indexOf("Android") != -1) {
actionAssignTag("mobile");
actionSaveData("MobileDevice", "Android");
return "true";
}
if (ua.indexOf("Windows Phone") != -1) {
actionAssignTag("mobile");
actionSaveData("MobileDevice", "Windows Phone");
return "true";
}
if (ua.indexOf("Windows CE") != -1 || ua.indexOf("Symbian") != -1
|| ua.indexOf("Nokia") != -1 || ua.indexOf("PDA") != -1) {
assignTag("mobile");
actionSaveData("MobileDevice", "Other");
return "true";
}
return "false"; // if mobile device not detected

If you have any questions, please contact us on help@rockcontent.com. 😀