Three ways to put a chat on the site
Most chat tools offer a WordPress plugin or a JavaScript snippet you paste in yourself. The third route is a chat you run yourselves, such as Chatwoot. That is what our own company sites use: the chat goes from Chatwoot to an AI agent in n8n.
Vendor plugin, embed snippet or self-hosted chat on WordPress
| Criterion | Vendor plugin | Embed snippet | Self-hosted (e.g. Chatwoot) |
|---|---|---|---|
| Set-up | install, log in, done | paste code into a header plugin or the theme | server, upkeep, updates |
| Control over loading | low, the plugin decides | high, you decide when | high |
| Consent | depends on the plugin | can wait for the banner | can wait for the banner |
| Where data lives | with the vendor | with the vendor | on your own server |
| Typical failure | extra scripts on every page | snippet sits above the banner and runs first | widget says “not available” |
A plugin is the easy option, but you also get whatever the plugin decides: usually a script on every page, often before the banner has been answered. The snippet gives you back control, and it is what we recommend whenever someone on the team can paste ten lines of code.
Self-hosting has its own traps. In our set-up Chatwoot showed “Vi er ikke tilgængelige” (we are not available) in the widget even though the AI agent answered around the clock. Chatwoot only counts human agents as online; switching on working hours and setting them to the whole day fixed it.
Speed: the widget is often the heaviest thing on the page
We measured chat widgets on the market at 155–750 KB of JavaScript, blocking the browser’s main thread for 300–600 ms. The cbot.dk widget, our own product, is 14 KB compressed and makes no third-party requests.
Whatever tool you pick, one technique matters most: show a light button and fetch the real widget only when it is needed. Most visitors never open the chat, so they never pay for it in waiting time. The button is plain HTML with no vendor script behind it.
Two WordPress specifics:
- Caching and optimisation plugins may delay or combine scripts, which can start the banner and the chat in the wrong order. Make sure the banner is excluded from “delay JavaScript”.
- Code placed in the theme’s
header.phpabovewp_head()runs before any plugin can block it. Move the chat code into a header plugin or a small theme function that useswp_enqueue_script.
What may the chat store before the banner is answered?
The Danish cookie order (cookiebekendtgørelsen) says you may not store or read information on the user’s device without consent based on adequate information. The exceptions are storage used solely to transmit a communication, and storage strictly necessary for a service the user has explicitly asked for. The joint guidance from Datatilsynet and Digitaliseringsstyrelsen adds that consent must be in place before cookies are set, and that saying no must be as easy as saying yes.
How we read that for a chat:
- When the page loads, nobody has asked for a chat. A widget that immediately writes a visitor id to a cookie or localStorage has to wait for consent.
- When the visitor clicks “Start chat”, they have asked for the service. What is strictly needed to keep that conversation going sits close to the exception. Vendor analytics, ad tags and “recognise returning visitors” do not.
- If you do not know what the widget stores, wait for consent. Open the site in a private window and check the browser’s Application tab before you click anything.
The banner only governs what is stored on the visitor’s device. It does not switch off your server logs, spam filtering or abuse rate limits, and the conversation stored on your server is a GDPR matter with a data processing agreement, not a cookie question. The cookie rules are supervised by Digitaliseringsstyrelsen, and Datatilsynet lists tracking on Danish websites as a 2026 focus area.
The loader: fetch the chat only after consent or a click
The snippet shows a button, waits for consent and only then loads the vendor script. It uses Lynbro Cookie Consent, our own free plugin on wordpress.org, which exposes a JavaScript function for the current consent and fires an event when the visitor chooses. With another banner, only the two lines using LynbroCookieConsent and lynbro_cc:consent need replacing with that banner’s own API.
(function () {
var WIDGET_SRC = 'https://chat.example.com/widget.js'; // the vendor's script
var CATEGORY = 'preferences'; // the banner category the chat belongs to
var LOAD_ON_CLICK = false; // true only if the widget stores nothing beyond what the chat needs
var loaded = false;
function loadWidget() {
if (loaded) return;
loaded = true;
var s = document.createElement('script');
s.src = WIDGET_SRC;
s.async = true;
document.head.appendChild(s);
var btn = document.getElementById('chat-facade');
if (btn) btn.remove();
}
function allowed(categories) {
return !!(categories && categories[CATEGORY]);
}
// A light button with no vendor script behind it
var btn = document.createElement('button');
btn.id = 'chat-facade';
btn.type = 'button';
btn.textContent = 'Chat with us';
btn.style.cssText = 'position:fixed;right:16px;bottom:16px;padding:12px 18px;border-radius:24px';
btn.addEventListener('click', function () {
var api = window.LynbroCookieConsent;
if (LOAD_ON_CLICK || (api && allowed(api.getConsent()))) return loadWidget();
if (api) api.openSettings(); // ask instead of guessing
});
document.body.appendChild(btn);
// Consent given on an earlier visit
var api = window.LynbroCookieConsent;
if (api && allowed(api.getConsent())) loadWidget();
// Consent given now
document.addEventListener('lynbro_cc:consent', function (e) {
if (allowed(e.detail && e.detail.categories)) loadWidget();
});
})();
Load the file in the footer (wp_enqueue_script with in_footer) so document.body exists; the banner itself must load earlier. Agree with whoever writes your cookie text which category the chat sits in: “preferences” fits a chat that remembers the conversation, “marketing” a widget that also tracks.
What banners on WordPress taught us
On 17 November 2026 we moved our own sites and the whole best-choice.dk network to our own plugins, including the cookie banner in the page’s language. Every switch went through a fixed gate: a parity table, a demo site, a visual review at 375, 768 and 1280 px in light and dark mode in Danish, English and Ukrainian, technical checks, and follow-ups after 24 hours and after 7 days.
Three faults we found on the way:
- A theme recoloured the “Reject” button until it almost disappeared. “Reject” now has the same colour as “Accept”; anything else is a dark pattern.
- A plugin package without translation files showed an English banner on Danish pages. WordPress silently falls back to English.
- Network activation on a multisite did not create the consent log on the subsites. Check that the log actually writes on every site.
The banner has about 100 active installs on wordpress.org and 5 stars from 3 ratings: a small, new plugin, and we say so. Finally, the AI disclosure: the chat must say it is an AI from the first message, and in cbot.dk that is on by default.
Sources
- Danish cookie order, BEK no. 1148 of 9.12.2011 — § 3 consent, § 4 exemptions, checked 20.11.2026
- Datatilsynet and Digitaliseringsstyrelsen – cookies guidance — consent before storage, refusal as easy as acceptance, May 2025
- Datatilsynet – focus areas 2026 — tracking on Danish websites
- Lynbro Cookie Consent on wordpress.org — our own product: script blocking, JS API and event, checked 20.11.2026
Questions about chat on WordPress
Plugin or embed code – which is better?
Embed code, if someone can paste ten lines. You then decide when the chat loads and can wait for the banner. A plugin is fine if it waits for consent by itself.
Does the chat need to be in the cookie banner?
Yes, if the widget stores or reads anything on the visitor’s device before they have asked for a chat. Most ready-made widgets do.
Will the chat slow the site down?
Often. The widgets we measured weighed 155–750 KB of JavaScript. Show a light button and load the widget on consent or click.
Can we use the loader with a different banner?
Yes. Replace the two lines that read the consent and listen for the choice with your banner’s own functions.
Fixed price, no commitment
Get a fixed price for your chatbot
Tell us briefly what you use today and what you want to achieve. A person answers by e-mail with a proposal and a fixed price before any work starts.
- A fixed price before we start
- An answer by e-mail, no calls
- Your details are used only to answer you