How can I add Facebook Messenger to Desktop website only?

Hi,
How can I add my FB Messenger script below to the Desktop website only?
Can I add the code in Settings → Custom Code?

I’ve tried the if (wixWindow.formFactor === “Desktop”) in many various ways without success.

Thanks ahead.


  <div id="fb-root"></div> 
  <script> 
    window.fbAsyncInit = function() { 
      FB.init({ 
        xfbml            : true, 
        version          : 'v9.0' 
      }); 
    }; 

    (function(d, s, id) { 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) return; 
    js = d.createElement(s); js.id = id; 
    js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js'; 
    fjs.parentNode.insertBefore(js, fjs); 
  }(document, 'script', 'facebook-jssdk'));</script> 

  <!-- Your Chat Plugin code --> 
  <div class="fb-customerchat" 
    attribution=setup_tool 
    page_id="XYZ"> 
  </div>

Put the desktop/mobile aside for a moment and explain how you planned to implement it (the exact solution may depend on your the answer, but anyway it’s via wixWindow.formFactor which is only relevant to Corvid).

Hi,
First of all, thanks.

Actually, I wanted to implement Messenger on desktop only as I have WhatsApp button on the mobile website and as Messenger occupies lots of sceen space there.

Implementing Messenger code as a Custom Code is straight forward (under Settings). However, once it’s implemented there, it applies both to Mobile and Desktop.

As I tried to apply it to the Desktop only, I tried playing with the custom code without luck.