There might be clients who prefer to have all three main components (Help Center search, Chat and contact form) of the Web Widget enabled, yet have the ability to offer a specific combination of them depending on the use case/web page. For instance, some might prefer to have only search functionality enabled on their homepage yet have solely chat enabled on critical pages such as checkout and have all three components enabled on the remainder of pages. In essence, customers have the ability to enable any combination of those 3 elements on any page of their site.
This can be achieved by using our set of Web Widget API endpoints to suppress the Help Center Search, Chat and Contact Form component. All the Web Widget endpoints are also explained and documented in Advanced customization of the Web Widget.
This script can help easily enable or disable various combination of components depending on necessity.
What it does:
- uses the Web Widget script that can be placed either directly on the page, or via Google Tag Manager (GTM);
- uses various API endpoints that will allow customers to customize various titles used on both Web Widget and Chat windows;
- uses the suppress API endpoints that allow us to deactivate specific components;
- uses Chat department routing depending on the status of the department, documented in more details in Recipe: Automatically route chats based on department online status.
The actual script:
To enable or disable a component, just change the relevant parameter in the runWidgetLogic.init function.
- If you want to enable only the search option, use: runWidgetLogic.init(true, false, false);
- To enable search and contact form use: runWidgetLogic.init(true, false, true);
- To enable only Chat: runWidgetLogic.init(false, true, false);
Elements in the code that will have to be updated:
- document.zendeskHost = 'mycompany.zendesk.com' => update "mycompany" with your subdomain);
- 'Department Name' => update with the name of your Zendesk Chat department.
- The titles or labels names used in the script can be updated on necessity.
To easily release the solution on a website, place the code (except for the runWidgetLogic.init(true, false, false); line) in a file (.js) added in the header section of the web page and then call the function via Google Tag Manager or directly in the web page by using a certain conditionality.