Jump to content

Zendesk open chat in another button


Recommended Posts

On the website we have the Zendesk module, with the button that when pressed opens the chat. My question is, I have created a tpl template in a theme in which there is a button that I would like to open the chat when pressed... but I can't. Anyone with knowledge of what I could do?

Link to comment
Share on other sites

  • 2 weeks later...
On 9/28/2023 at 2:35 PM, ednukros said:

I have created a tpl template in a theme in which there is a button that I would like to open the chat when pressed... but I can't. Anyone with knowledge of what I could do?

Hi,

First, you need to find the HTML button element in your custom .tpl template file. Look for the button's ID or class, or any other attribute that can be used to select the button using JavaScript.

You will need to include the Zendesk Web Widget script in your template if it's not already included.

After including the Zendesk script, you can write custom JavaScript code to trigger the chat widget to open when the button is clicked. Make sure to include this code below the Zendesk script you added earlier.

<script>
document.getElementById('your-button-id-or-class').addEventListener('click', function() {
    // Open the Zendesk chat widget when the button is clicked
    zE('webWidget', 'open');
});
</script>

Replace 'your-button-id-or-class' with the actual ID or class of your button element.

After making these changes, clear the cache and check if the changes take effect.

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...