Recent searches


No recent searches

Hiding the Chat widget on mobile devices

Answered


Posted Mar 26, 2021

This is a continuing discussion about the article Hiding the Chat widget on mobile devices in the developer documentation.


0

5

5 comments

image avatar

Andrew J

Community Moderator

Not working. Using as below.

`<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase(), platform = navigator.platform.toLowerCase();
platformName = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0],
isMobile = /ios|android|webos/.test(platformName);
if (!isMobile) {
id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=e87=my-key=4e"
}
</script>`

0


image avatar

Charles Nadeau

Zendesk Documentation Team

Please note that this article applies to Chat-only accounts. There are two main types of Chat accounts:

  • Chat-only offers Zendesk Chat communication with your customers, and nothing else.
  • Chat + Support combines Zendesk Chat with a Zendesk Support account, which allows you to share data and functionality between the two products.

See About Chat account types in the Chat Help Center.

The embed code varies between the two. The Chat-only embed code looks as follows:

<script>window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
$.src="https://v2.zopim.com/?2LOuzDNZKZgAjXUrtRuXlGJ0Iiwx4A6t";z.t=+new Date;$.
type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");</script>

The Chat+Support embed code looks like Andrew's snippet above:

<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=e87=my-key=4e"></script>

I'll update the introduction to make this clearer.

0


Ah, thanks Charles, that makes sense! 

So how can we hide the widget on mobile if we have a Chat+Support account?

0


For chat + support account, you can hide the widget on mobile by following code snippet
<script>

var ua = navigator.userAgent.toLowerCase(), platform = navigator.platform.toLowerCase();

platformName = ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0],

isMobile = /ios|android|webos/.test(platformName);




if (!isMobile) {

  var script = document.createElement('script');

  script.id = 'ze-snippet';

  script.src = 'https://static.zdassets.com/ekr/snippet.js?key=mykeyhere';

  document.head.appendChild(script);

}

</script>
 

0


Thanks for that Muvluv1987!

0


Post is closed for comments.

Didn't find what you're looking for?

New post