Controlling the Widget

If you want to customize the Drift widget beyond what is offered through the Drift application, you can use JavaScript to control aspects of our widget manually. Below are some examples of controlling the widget, and more detailed documentation can be found here.

Initializing the Drift Widget

The ready event indicates that Drift widget is ready for use. It contains a single argument which is the actual API object that can then be acted upon.



This script should live inside your section on your webpage.
It should also always come after the Javascript snippet you copy pasted to install Drift.

drift.on('ready',function(api, payload) {
 // interact with the api here

Code Example: customize widget using Widget API

The following snippet uses the hide() and show() functions and the chatOpen and widgetVisible events to hide the widget from users until they receive a message.

  // hide the widget when it first loads
 // show the widget when you receive a message
  // hide the widget when you close the chat

Not using Drift yet? Get your free account here!

Updated 9 months ago

Controlling the Widget

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.