Prevent Landbot from loading in mobile browsers

Pau Sanchez Updated by Pau Sanchez

Due to design or speed, we might want to avoid Landbot being displayed and loaded in Mobile devices, here is a sample code to do that:

<script>
document.addEventListener('DOMContentLoaded', function() {
let checkMobile = (/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(navigator.userAgent)) ? true : addLandbot(); }); function addLandbot(){
var scriptstatic = document.createElement("script");
scriptstatic.src = "https://static.landbot.io/landbot-3/landbot-3.js";
scriptstatic.onload = function() {
var script = document.createElement("script");
script.type = "text/javascript";
var code = document.createTextNode(`
var myLandbot = new Landbot.Livechat({
configUrl: 'https://chats.landbot.io/v3/H-1234-XXXXXX/index.json',
});
`);
script.appendChild(code)
document.body.appendChild(script)
}
document.body.appendChild(scriptstatic)
} </script>

Just change the url of the "configUrl" for the one assigned to your bot:

configUrl: 'https://chats.landbot.io/v3/H-1234-XXXXXX/index.json',

Change only this part H-1234-XXXXX , you will find your in the Share Section:

How did we do?

Conditional Welcome: Direct the Flow of Your Bot Based on External Parameters

How to not display Proactive Message to repeating Visitors

Contact