| Purpose | Add a floating WhatsApp Messenger button to your hosted Cloudbeds Booking Engine Plus. |
| Best for | Property administrators, managers, and owners responsible for Booking Engine customization. |
| Use this when | You want guests to contact your property through WhatsApp while visiting your Booking Engine, or you need to replace an older WhatsApp button customization that no longer appears. |
| Requirements | Access to the Booking Engine Customize tab, including the Custom Meta Tags and Custom JavaScript fields, and a WhatsApp phone number with its international country code. |
| Expected result | A floating WhatsApp button appears on your hosted Booking Engine, allowing guests to open WhatsApp and contact your property. Guests can also dismiss the button using the X icon. |
| Limitations | This customization applies to the hosted Booking Engine only. It does not apply to the Immersive Experience embedded on your property's website. |
Introduction
Adding a WhatsApp Messenger button to your Cloudbeds Booking Engine Plus gives guests a convenient way to contact your property while browsing accommodation options.
This customization adds a floating WhatsApp button and a small X icon that guests can use to dismiss it. The button opens WhatsApp using the phone number configured by your property.
To make the button display correctly, its styling must be added to Custom Meta Tags, while the JavaScript creates the button and handles its behavior. This is especially important if you previously used an older version of the customization that placed the button's HTML directly in Custom Meta Tags.
Important: These instructions are for the hosted Booking Engine, not the Cloudbeds Booking Engine Immersive Experience 2.0 embedded on your property's website.
Table of contents
- Add a floating WhatsApp button to your Booking Engine
- Verify that the WhatsApp button works
- Troubleshoot a missing or incorrectly displayed button
Add a floating WhatsApp button to your Booking Engine
The customization requires two code snippets: CSS to define the button's appearance and JavaScript to create the button and its close control.
Follow the steps below to add both snippets to your hosted Booking Engine.
Step 1: Add the CSS to Custom Meta Tags
- Go to Account Menu
> Settings > Booking Engine.
- Open the Customize tab.
- Locate the Custom Meta Tags section.
- Copy the CSS code below and paste it into the field. If you previously added the old WhatsApp customization, replace its WhatsApp-related code with this version.
- Click Save.
Before replacing existing code: If your Custom Meta Tags field already contains other customizations, such as Google Tag Manager or website verification tags, keep those entries intact. Remove or replace only the old WhatsApp-related code.
Custom Meta Tags CSS:
<style>
.cb-floating-whatsapp {
position: fixed;
width: 60px;
height: 60px;
bottom: 70px;
right: 25px;
background-color: #25d366;
color: #FFF;
border-radius: 50px;
display: flex;
align-items: center;
justify-content: center;
text-decoration: none;
font-size: 30px;
z-index: 10000;
}
.cb-floating-whatsapp-close {
position: fixed;
width: 20px;
height: 20px;
bottom: 125px;
right: 20px;
background-color: #25d366;
color: white;
border: none;
font-size: 20px;
z-index: 10001;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
}
.cb-floating-whatsapp-close i {
font-size: 15px;
font-weight: 700;
}
</style>This code controls the button's size, color, appearance, and position on the Booking Engine. The JavaScript in the next step creates the actual button.
Step 2: Add the WhatsApp JavaScript
The JavaScript creates the WhatsApp button and its close control after the page is ready, preventing the button from being removed by the Custom Meta Tags HTML filtering.
- Stay on the Booking Engine > Customize tab.
- Locate the Custom JavaScript section.
- Copy the code below and paste it into the field. If you have an older WhatsApp script, replace only that script. Preserve any unrelated JavaScript customizations.
- Find
1234567890in the code and replace it with your property's WhatsApp phone number, including the international country code. - Click Save.
Phone number format: Enter your full international phone number using digits only, without the plus sign (+), spaces, parentheses, or dashes. For example, use 1234567890 as a format reference, not as an actual property number.
Custom JavaScript:
<script>
function addWhatsAppButton() {
if (document.querySelector('.cb-floating-whatsapp')) return;
// Inject FontAwesome
if (!document.querySelector('link[href*="font-awesome"]')) {
var fa = document.createElement("link");
fa.rel = "stylesheet";
fa.href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css";
document.head.appendChild(fa);
}
// Create the WhatsApp button
var waButton = document.createElement("a");
waButton.href = "https://api.whatsapp.com/send?phone=1234567890";
waButton.className = "cb-floating-whatsapp";
waButton.target = "_blank";
waButton.rel = "noopener noreferrer";
waButton.innerHTML = '<i class="fa-brands fa-whatsapp"></i>';
// Create the Close button
var closeButton = document.createElement("button");
closeButton.className = "cb-floating-whatsapp-close";
closeButton.setAttribute("type", "button");
closeButton.setAttribute("aria-label", "Close WhatsApp button");
closeButton.innerHTML = '<i class="fa-solid fa-xmark"></i>';
// Append to body
document.body.appendChild(waButton);
document.body.appendChild(closeButton);
// Close action
closeButton.addEventListener('click', function() {
waButton.style.display = 'none';
closeButton.style.display = 'none';
});
}
// State check for SPA
if (document.readyState === 'loading') {
document.addEventListener("DOMContentLoaded", addWhatsAppButton);
} else {
addWhatsAppButton();
}
</script>Important: The CSS and JavaScript must both be saved for the customization to work correctly. Do not place the WhatsApp button HTML elements directly into Custom Meta Tags, as they may be removed by the Booking Engine's security filtering.
Verify that the WhatsApp button works
After saving both code snippets, open your hosted Booking Engine to confirm that the floating button appears and works as expected.
- Open your hosted Booking Engine in a browser.
- Confirm that the green WhatsApp button appears near the bottom-right corner of the page.
- Click the WhatsApp button and verify that it opens WhatsApp using your property's phone number.
- Return to the Booking Engine and click the X icon to confirm that the button can be dismissed.
- Review the button's appearance on both desktop and mobile devices to confirm that it does not cover essential Booking Engine controls.
The image below illustrates the floating WhatsApp button and its close control on the Booking Engine.
Check the button position: If you adjust the size or placement of the WhatsApp button, make sure it does not overlap essential Booking Engine buttons or other controls on desktop or mobile devices. An experienced website designer or developer can assist with advanced customization.
Troubleshoot a missing or incorrectly displayed button
If the WhatsApp button does not appear or behaves unexpectedly, review the configuration before making further changes.
- The button does not appear: Confirm that the CSS is saved in Custom Meta Tags and that the updated script is saved in Custom JavaScript. Remove any old WhatsApp button HTML from Custom Meta Tags.
-
The WhatsApp link opens the wrong number: Check that you replaced
1234567890with the correct international phone number using digits only. - The button appears without the expected icon: Check that the Font Awesome stylesheet reference in the JavaScript has not been changed or removed.
- The button covers other Booking Engine controls: Review its CSS positioning and test the layout on both desktop and mobile devices.
- The property uses Immersive Experience: This customization is intended for the hosted Booking Engine and is not supported by these instructions for an embedded Immersive Experience.
If the issue continues, contact Cloudbeds Support and provide:
- The URL of the hosted Booking Engine where the issue occurs.
- A description of what happens when the button is displayed or clicked.
- Any relevant screenshots, and the customization checks you have already completed.
Next Operational Step
Once the floating WhatsApp button is working, verify that it remains accessible throughout the guest's booking journey and that it opens the correct WhatsApp contact on both desktop and mobile devices.
Comments
This sounds like a great feature... could you please provide the code for the "Booking Engine Plus" users?
Hello, Karl brochard!
You can find the required instructions for Booking Engine Plus in the section WhatsApp Messenger for Booking Engine Plus of this article.
Please let us know if you need any other information.
Kind regards! 💙
Please sign in to leave a comment.