1. Home
  2. Troubleshooting
  3. How could one stop WebEngage from being shown on mobile?

How could one stop WebEngage from being shown on mobile?

If you are worried about the looks, we would like to let you know that WebEngage is mobile responsive.
In case you still want to prevent WebEngage on mobile devices, you need to use the JavaScript code below, along with your integration code. Make sure to replace the LICENSE_CODE with your own.

var _weq = _weq || {};
_weq['webengage.licenseCode'] = '_LICENSE_CODE_';

var isMobile = {
    Android: function() {
            return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
            return navigator.userAgent.match(/IEMobile/i);
    },
    any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};

if (isMobile.any()) {
    _weq['webengage.defaultRender'] = false;
}

You may also try the following code – which would stop WebEngage on devices with screen resolution lesser than 800×600. It will eliminate most of the mobile devices.

  var window._weq = {};
  _weq['webengage.licenseCode'] = '_LICENSE_CODE_';
  var isMobileDevice = function () {
    var minHeight = 800;
    var minWidth = 600;
    var availWidth = window.screen.availWidth;
    var availHeight = window.screen.availHeight;
    return (availHeight <= minHeight && availWidth <= minWidth ? true : false);
  };

  if (isMobileDevice()) {
    _weq['webengage.defaultRender'] = false;
  }

Was this article helpful?