How to add Chat Functionality snippet

I am trying to add a chat functionality to my website. I have a snippet that needs to be placed on the site just before the closing tag on every page. (see below)

I have tried adding it to the page using an html stack and also the Javascript code in the tools bar but it doesnt work in preview with either of these. Any ideas?