Gorgias logo
Gorgias logo

All articles

Display the chat widget after some time spent on the websiteUpdated 2 months ago

To only display the chat after a certain amount of time, use the following method:

1<script>
2var initGorgiasChatPromise = (window.GorgiasChat) ? window.GorgiasChat.init() : new Promise(function (resolve) { window.addEventListener('gorgias-widget-loaded', function () { resolve();})});
3
4initGorgiasChatPromise.then(async function() {
5    var chatElem = document.getElementById("gorgias-chat-container")
6    chatElem.style.display = "none";
7
8    function sleep(seconds) {
9    return new Promise(resolve => setTimeout(resolve, seconds * 1000));
10    }
11
12    await sleep(5) // CHANGE THIS VALUE TO THE NUMBER OF SECONDS TO WAIT BEFORE SHOWING THE CHAT BUBBLE
13    chatElem.style.display = "";
14})
15</script>
Was this article helpful?
Yes
No