Skip to main content
Answered

How to trigger intercom chat when a link or button is clicked on WordPress.


I want to assign a function to a button in Elementor that says Chat with us and when clicked, an intercom chat pops up

Best answer by User677

Behold; the Javascript API: https://developers.intercom.com/installing-intercom/docs/intercom-javascript#intercomshownewmessage/p>

 

These methods are pretty easy to implement and set up. On "Intercom('showNewMessage')" note there is a Pre-Population of message option, so the chat window can open, with a new message. This can help if you want to prompt people with a specific starting message for the new chat.

View original

4 replies

  • Connector
  • 8 replies
  • Answer
  • July 11, 2022

Behold; the Javascript API: https://developers.intercom.com/installing-intercom/docs/intercom-javascript#intercomshownewmessage/p>

 

These methods are pretty easy to implement and set up. On "Intercom('showNewMessage')" note there is a Pre-Population of message option, so the chat window can open, with a new message. This can help if you want to prompt people with a specific starting message for the new chat.


  • Author
  • New Participant
  • 1 reply
  • July 11, 2022

Thanks @user677​ for your swift response.

 

<script>

  document.querySelector("#my_custom_link").addEventListener("click", ()=>{

  Intercom("show")

})

</script>

 

So I added this script using Insert Headers and Footers but it didn't work unfortunately

 

 


  • Connector
  • 8 replies
  • July 13, 2022

Hey there - I'm unable to troubleshoot your Javascript. You're best working with a developer to get into your site and handle that. I'm also unsure what CMS/platform you're using referencing "Insert Headers and Footers"

 

But as some general advice — assuming you have the selector of the button correct (#my_custom_link), my guess is that the Javascript is loading before the button on your site loads. So the "addEventListener" isn't getting attached to the button. The button has to be loaded in the DOM first by the time the Javascript is in the page code.

 

I'd recommend looking into Javascript code to add here that waits for your entire page DOM to load, THEN does the code you already have. You could also just make your button link 'javascript:Intercom("show")' assuming your CMS allows that.


Nur Nahid
Super User ✨
Forum|alt.badge.img+3
  • Super User ✨
  • 95 replies
  • October 29, 2024

You can follow this guide to setup intercom chat to your wordpress website


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings