How to Add the DiveChat Live Chat to a Website on a VPS

How to Add the DiveChat Live Chat to a Website on a VPS

  1. Home
  2. Blogs
  3. How to Add the DiveChat Live Chat to a Website on a VPS

Partner guide: PSB Hosting × DiveChat.

A live chat on your website gives visitors a quick way to ask a question at the moment they are ready to buy, instead of filling in a form and waiting. If your site runs on a VPS, adding a chat widget takes a few minutes, but server settings such as HTTPS, security headers and caching can stop it from appearing.

This guide shows how to add the DiveChat live chat to a WordPress site or a site on your own engine hosted on a VPS, which server settings to check, and how to test the chat before you announce it.

What You Need Before You Start

Prepare three things: a working site on HTTPS, access to its templates or admin panel, and a DiveChat account.

What Where to find it Why it matters
A site on HTTPS Your web server config (nginx or Apache) and SSL certificate Browsers block or warn about scripts on insecure pages
Access to templates or WordPress admin SSH/SFTP to the server or the WordPress dashboard The widget code must be placed on every page
A DiveChat account divechat.ru The widget code is generated in your account
A list of security headers Server config or security plugin A strict Content-Security-Policy can block the widget

If you are still choosing a server for the site, any PSB Hosting VPS gives you root access, so you can change web server settings yourself.

Step 1. Get the Widget Code in DiveChat

The widget is a short JavaScript snippet generated in your DiveChat account. You add it to your site once, and the chat appears on every page that contains it.

  1. Sign up or log in at DiveChat.
  2. Add your website as a channel in the account settings.
  3. Copy the widget code that DiveChat generates for that site.
  4. Keep the code in a text file: you will paste it in the next step.

DiveChat says the widget can be launched without developers; the exact menu names may change, so follow the current instructions in your account.

Step 2. Add the Code to WordPress

On WordPress, the safest way is a plugin that inserts code into the site footer, because theme updates do not overwrite it.

  1. In the WordPress dashboard, open Plugins → Add New and install a plugin for inserting header and footer code (for example, WPCode).
  2. Open the plugin settings and paste the DiveChat code into the footer section.
  3. Save the changes and clear the cache if you use a caching plugin.

Option B: a child theme

If you prefer not to add a plugin, paste the code into the footer.php file of a child theme, right before the closing </body> tag. Do not edit the parent theme: the next update will remove your changes.

Step 3. Add the Code to a Custom Engine or a Static Site

On your own engine, paste the code once into the base layout template that every page uses, right before </body>.

For a static site served by nginx, you can either add the code to every HTML file or let nginx insert it into all pages with the sub_filter directive:

location / {
    sub_filter '</body>' '<!-- DiveChat widget code --></body>';
    sub_filter_once on;
    # ...your existing directives
}

Replace the comment with the code from your DiveChat account, then check the config and reload nginx:

sudo nginx -t && sudo systemctl reload nginx

The sub_filter directive comes from the ngx_http_sub_module, which is included in most distribution builds of nginx. Test it on one page first: if responses are compressed by an upstream application, the replacement will not work.

Step 4. Check the Server Settings That Block the Widget

If the code is in place but the chat does not appear, the cause is almost always on the server side: insecure content, security headers or caching.

Symptom Likely cause What to do
The chat does not appear, the browser shows a warning The page or some resources load over HTTP Redirect all traffic to HTTPS and fix mixed content
The console shows a "Content Security Policy" error Your CSP header does not allow the widget domains Add the domains listed in the DiveChat instructions to script-src, connect-src and frame-src
The chat appears only after a hard refresh An old version of the page is cached Clear the plugin, server and CDN cache
The chat works on desktop but not on mobile A separate mobile template or AMP pages without the code Add the code to the mobile template too
The chat loads slowly or not at all A script optimizer defers or combines the widget script Exclude the widget script from minification and deferral

You can see errors in the browser console: press F12, open the Console tab and reload the page.

Step 5. Test the Chat Before Launch

Test the chat as a visitor would, from the first message to the reply in the operator panel.

  1. Open the site in an incognito window and make sure the widget appears on the home page and on a few inner pages.
  2. Send a test message and check that it arrives in the DiveChat operator panel.
  3. Reply from the panel and confirm the visitor sees the answer.
  4. Repeat the test on a phone.
  5. If you connect messengers, the AI operator or a CRM, send one more test message and check that the conversation history is saved.

DiveChat states that its AI operator can answer routine questions and create deals in a CRM; details and current plans are on the DiveChat website.

Keep the Site Fast and Stable

A chat widget adds one more script to every page, so it is worth keeping an eye on server resources and page speed.

  • check page load time after adding the widget;
  • keep the web server, PHP and WordPress plugins updated;
  • set up monitoring so you know if the site goes down;
  • move to a larger plan or a dedicated server when traffic grows.

DiveChat users get 15% off a PSB Hosting order with the promo code DIVECHAT (one use per customer). More server guides are on the PSB Hosting blog.

Related articles

403 Forbidden Error: Causes and How to Fix It

403 Forbidden Error: Causes and How to Fix It

A 403 Forbidden error means the server understood the request but refuses to fulfil it: access to the page or file is not allowed. Unlike 5xx errors, the server is working here — it has simply d

9HTTP: Global Proxy IP Solutions for Cross-Border Business and AI Applications

9HTTP: Global Proxy IP Solutions for Cross-Border Business and AI Applications

Partner content: 9HTTP. As businesses expand into global markets, data collection, market research, SEO monitoring, ad verification, and AI-related applications require increasingly diverse network e

504 Gateway Timeout and Error 524: Causes and How to Fix Them

504 Gateway Timeout and Error 524: Causes and How to Fix Them

Errors 504 and 524 mean essentially the same thing: the server took too long to respond and the intermediary stopped waiting. The difference is who gave up waiting — your web server or Cloudflar

How to Automate CAPTCHA Solving on a VPS with CaptchaAI

How to Automate CAPTCHA Solving on a VPS with CaptchaAI

Partner content. Prepared by the CaptchaAI team. Moving an automation project to a VPS solves one problem: the application no longer depends on someone keeping a laptop open. But a server that sta

VPN vs VPS: What's the Difference and Which One Do You Need?

VPN vs VPS: What's the Difference and Which One Do You Need?

VPN and VPS are easy to mix up: the abbreviations look alike, and both come up in conversations about servers and security. In reality they are completely different things. Let's look at the differenc

Mobile Proxies on a VPS: Building Reliable Workflows for Social Media and Automation

Mobile Proxies on a VPS: Building Reliable Workflows for Social Media and Automation

Teams that manage dozens of social media accounts or run automation eventually arrive at the same setup: a server that runs 24/7 and mobile proxies that carry that traffic to the internet. Here is how

500 Internal Server Error: Causes and How to Fix It

500 Internal Server Error: Causes and How to Fix It

500 Internal Server Error means something went wrong on the server — but the server won't tell the visitor what. It's the least informative error: it has dozens of possible causes. The good news

Buysellacc.com: a Platform for MMO Accounts and Digital Services

Buysellacc.com: a Platform for MMO Accounts and Digital Services

Partner content. Prepared by the Buysellacc team. Buysellacc.com is a platform with an automated system for MMO accounts and digital services. It works for individuals, collaborators, resellers and b

How to Connect to a Server via SSH: Windows, macOS and Linux Step by Step

How to Connect to a Server via SSH: Windows, macOS and Linux Step by Step

SSH is the standard way to manage a VPS or dedicated server: you use it to install software, edit configs, read logs and restart services. This guide shows how to connect to a server via SSH from Wind

Telegram