Install Yaplet on Drupal

Updated October 22, 2026

Drupal itself has no setting for adding a script to every page, but the free Asset Injector module adds one, and that is all the Yaplet widget needs. You install the module, paste one block of code from Yaplet into a new JS injector, and the chat button appears on your site. Asset Injector works with Drupal 10.3 and newer, including Drupal 11, and Drupal's security team covers its stable releases.

Installing a module needs an administrator account and, usually, Composer on your server. If you don't manage the site yourself, send this guide to your developer.

1. Install the Asset Injector module

  1. On your server, in your Drupal project, run the Composer command from the module's page:
composer require 'drupal/asset_injector:^2.21'
  1. In Drupal, go to Extend, check Asset Injector and click Install.

Give the Administer JS Assets permission only to roles you fully trust: anyone who has it can add JavaScript to every page of your site.

2. Copy your Yaplet code

In the Yaplet dashboard's left menu, click Chat widget under your brand's name and open the Install tab. Under Where does your website run?, choose Other website and switch off Include the <script> and </script> lines. Copy the code with the copy button on the code block.

The code must be plain JavaScript that starts with !function (Yaplet, with no <script> tags around it. If what you copied starts with a <script> line, leave out that first line and the last </script> line. Asset Injector wants the code without these tags and refuses to save it with them.

3. Add a JS injector

  1. Go to Configuration → Development → Asset Injector → JS Injector.
  2. Click Add JS Injector.
  3. In Label, type a name you will recognize later, for example Yaplet chat.
  4. Paste the code you copied into the Code field.
  5. Make sure Enabled is checked.
  6. Leave the conditions empty, so the code loads on every page.
  7. Click Save.

You can leave the advanced options as they are: the chat doesn't need jQuery, and loading the script in the footer (Drupal's default) works fine. With no conditions, the chat also appears on your admin pages. To show it only on your public site, set the Current Theme condition to your site's front-end theme.

4. Check your site

Asset Injector clears Drupal's caches when you save. Open your site in a new browser tab and reload the page. The Yaplet chat button appears in the bottom-right corner. Click it to check that the chat opens.

For a full checklist, see Verify your installation.

If the chat doesn't appear

  • Drupal says there must be no leading or trailing <script> tags. Remove the first <script> line and the last </script> line, so the code starts with !function (Yaplet.
  • The injector is switched off. Edit it, check Enabled and save.
  • A condition hides the chat. Conditions limit the pages the code loads on. If you set the Current Theme condition, check that it names the theme your public site uses.
  • Your browser shows an old copy of the page. Reload the page, or open your site in a private window.

What's next

To see what the code does and where your widget ID is, read Install Yaplet.

Did this article answer your question?