Note: This guide applies only to the Chat widget from Chat-only accounts, not from Chat+Support accounts. See About Chat account types in the Chat Help Center.
You can hide the Chat widget from visitors on mobile devices.
-
Paste the following script tag in the head of the page or pages that have the widget.
<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) { //place your chat embed code here without the <script> tags } </script>
The first part of the script determines whether or not the web client is a mobile device. The second part displays the widget only if it's not a mobile device.
-
Move the widget embed code to the location in the script above.
In this case, remove the script tags that normally enclose the embed code.
7 Comments
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>`
Can we get an update on this? The suggested fix doesnt seem to take into account the usual embed code (Andrew Mills' response here shows the incorrect fix if the instructions are followed exactly )
Please note that this article applies to Chat-only accounts. There are two main types of Chat accounts:
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:
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.
Ah, thanks Charles, that makes sense!
So how can we hide the widget on mobile if we have a Chat+Support account?
Thanks for that Muvluv1987!
Please sign in to leave a comment.