Integration of Live Chat using Google Tag Manager

Status
Not open for further replies.

Jan Prepletany

Free User
Joined
Aug 2, 2024
Messages
3
Reaction score
0
Hi, has anobody tried to integrate the Live Chat using Google Tag Manager (GTM). Our corporate sites prohibit to place script directly into HTML code and we have to use GTM, however when we tried to paste the below code of the Live Chat script into GTM we received an error message saying that it is invalid HTML code...GTM thus does not allow to save this script and we are stuck.

Direct link to Live Chat works well, however I would like the Live Chat to be started and displayed automatically when our websites are displayed to a customer in their HTML browser.
Any ideas what is wrong?
1722614424393.png
 
Just rewrite that to make it a bit more dynamic (put the code below inside script tags):
// Create and append the custom element after the page loads
(function() {
function loadCustomElement() {
var callUsSelector = document.createElement('call-us-selector');
callUsSelector.setAttribute('phonesystem-url', 'https://your_3cx_address');
callUsSelector.setAttribute('party', 'your_organization');
document.body.appendChild(callUsSelector);

// Load the external script after appending the custom element
var script = document.createElement('script');
script.src = "https://downloads-global.3cx.com/downloads/livechatandtalk/v1/callus.js";
script.id = "tcx-callus-js";
script.charset = "utf-8";
document.body.appendChild(script);
}

// Wait for the DOM to fully load before executing the function
if (document.readyState === 'complete') {
loadCustomElement();
} else {
window.addEventListener('load', loadCustomElement);
}
})();
 
  • Like
Reactions: Jan Prepletany
Status
Not open for further replies.

Forum statistics

Threads
112,147
Messages
590,961
Members
165,167
Latest member
Finatra.us