Initializing

Markdown

View as Markdown

While a webpage containing the snippet code is loading, you can make changes to its configuration using the following two methods.

collectchat.ready = function

All methods and callbacks are executed using the global variable collectchat. To make sure the chat widget content and objects are loaded properly, use the collectchat.ready method.

var collectchat = window.collectchat || {};
collectchat.ready = function() {
  //Place your code here
}

Note: Using other methods of our JavaScript API outside collectchat.ready may not produce proper results.

collectchat.config(settings)

You can change the configuration of the chat widget using this method. The following attributes are available:

AttributeTypeDefaultDescription
launchModeString'launcher'Choose between the default 'launcher' or your own 'custom' button. Setting this to 'custom' hides the provided launcher; you'll implement your own button using collectchat.open.
welcomeMessageNumber1Provide a custom welcome message by passing the question number. You can set a personalized start question based on user actions and characteristics. Passing 0 hides the welcome message.
launcherTextString''Provide a custom message for the Launcher Text, e.g. a personalized greeting with the user's name. The welcome message in the design section should be OFF for this to work.
showMessageAfterCloseBooleantrueSetting this to false hides the welcome message bubble after the user has closed the chat widget once.
avatarURLNoneSet the image displayed inside the launcher by providing an absolute URL.
saveDataBooleantrueSetting this to false stops responses from being saved on our servers. Use this only for strict privacy compliance needs.
openOnLoadBooleanfalseSetting this to true opens the chat widget by default when the page loads.
skipIpBooleanfalseSet this to true if you don't want to collect the user's IP address.
var collectchat = window.collectchat || {};
collectchat.ready = function() {
  collectchat.config({
    launchMode: 'launcher',
    welcomeMessage: 1,
    showMessageAfterClose: true,
    avatar: 'https://collect.chat/image/ccdark.png',
    saveData: true,
    openOnLoad: false
  });
}

What's Next

Related Articles

Was this article helpful?