Chatbot for PHP Website Projects: Add One Footer Include, Cover Every Template and Pass the Logged-In User Safely (Free Template Audit Checklist)
Chatbot for PHP website setups is easier than most owners expect, because PHP sites usually share a header and footer file. Add the LiveChatBot embed script to the footer include once and every page that uses it gets chat. The real work is finding the pages that do not use it. This guide shows the include, the escaping rule for logged-in names, and an audit checklist.
โก In short
- Plain PHP sites need no plugin: paste the embed script into the shared footer file.
- Pages that print their own HTML, such as old landing pages and invoices, will be missed. Audit for them.
- Escape anything you print into JavaScript with json_encode, never by string concatenation.
- Use the checklist below after every change to your templates.

Why PHP is easy
Why a chatbot for PHP website code is mostly a footer edit
PHP grew up as a templating language, so most sites, from a hand-built brochure site to a custom shop, already split a page into pieces: `header.php`, `footer.php`, maybe `sidebar.php`. Those files are the natural home for a chat script.
LiveChatBot is installed with one embed script. There is no PHP library to require, no Composer step and no server-side code that talks to the chat. That keeps your hosting simple. A basic shared host works, because the script runs in the visitor’s browser and loads from livechatbot.in.
So the plan has three parts: add the script once, find every page that bypasses your shared files, and decide what extra data, if any, to pass from PHP to the chat. The sections below take them in that order.
The include
Step one: the footer line
Open the file that prints the end of your pages, usually `footer.php`, and paste the embed script just before the closing body tag. You will find your widget key on the install page of your dashboard after you create a free account.
Keep the key in one place
If you have a config file, define the key once, for example as a constant, and print it in the tag. That way staging and live sites can use different keys, or none at all. Leaving the constant empty on staging avoids counting test traffic against your monthly visitor allowance.
Do not edit in the browser
Make the change in your files, upload it, and view the page source on the live site. If the script tag is not there, a cache, an old copy of the file or a different include path is the usual reason.
The copy-ready box below has the tag and the guarded version.
Try it
Copy-ready PHP lines for a chatbot for PHP website pages
Three tabs: the footer tag with a guard, a safe logged-in call and a staging switch. Replace the placeholders with your own names.
Safety
Step two: print user data into JavaScript the safe way
If your site has logins, you may want agents to see who they are talking to. The JavaScript API call `window.LiveChatBot.setVisitor` takes details such as a name and email.
The risk is how PHP builds the line. Joining strings by hand breaks on an apostrophe in “O’Brien” and, worse, can open a script injection hole. Use `json_encode` with the HEX flags, as in the snippet above. It produces a valid JavaScript object and neutralises quotes and angle brackets.
Two more rules. Send only what your team needs, and say in your privacy notice that website chat is used. If you need other API calls, the chat also offers `open`, `close`, `show`, `hide`, `sendMessage`, `pageView` and an `on` listener. For anything beyond that, ask our team for developer documentation.
Coverage
Step three: find the pages your footer never reaches
On older PHP sites, a shared footer rarely covers everything. Typical misses are standalone landing pages saved as full HTML, thank-you pages, printable invoices, a blog that lives in a subfolder with its own template and any page built by a page-builder plugin.
How to find them
Crawl your own site, or list every file that outputs a closing body tag. Search your project for that tag and compare the list with the files that include the footer. Any file in the first list but not the second needs the script, or a deliberate decision to leave chat off.
Decide, don’t default
Not every page should have chat. Payment steps and admin screens are better without it. The dashboard’s “where it shows” setting can hide the chat on chosen pages without editing code, which suits rules like “never on /checkout”. See the guide to showing chat on specific pages.
Audit
Template audit checklist
Tick each step as you finish it. Nothing is saved or sent.
After launch
Keeping a chatbot for PHP website templates healthy
Templates change. A redesign, a new theme folder or a developer’s quick fix can quietly drop the footer include, and nobody notices until the enquiries slow down.
Make the check routine
Add one line to your deployment notes: after every release, open the home page and one inner page, check the bubble and send a test message. If you use version control, keep the footer file in it so a change is easy to review.
Watch the numbers
Your dashboard’s visitor tracking shows which pages people are on when they start chats. If a section of the site never appears there, the script is probably missing from that template. That is a cheap, early warning.
Limits
What the chat will not do for PHP code
Be honest about the limits so you plan around them.
- No PHP library, SDK or framework plugin exists. Install is the embed script only.
- The chat does not connect to your database, so it cannot look up orders or accounts.
- The AI Agent answers from the knowledge you give it. When its allowance runs out, a free keyword bot answers from saved replies.
- No WhatsApp inbox and no iPhone team app. “Powered by LiveChatBot” stays on all plans.
If your PHP code must react to events, tickets send webhooks when they are created or solved, and there is a REST API and Zapier. See the integrations page.
Frequently asked questions
Do I need a library for a chatbot for PHP website use?
No. Paste the embed script into the shared footer file. There is no PHP package.
Will it work on cheap shared hosting?
Yes. The script runs in the visitor’s browser and loads from livechatbot.in, so your host only serves the page.
Why is the chat missing on some pages?
Those pages probably do not use the shared footer. Search for files that print a closing body tag and add the script or skip them deliberately.
How do I pass a logged-in name safely?
Use json_encode with the JSON_HEX flags to build the object for setVisitor, rather than joining strings.
Is there a free plan?
Yes. Two websites, 100 free visitors per website each month and no per-seat charges.
Keep reading
Related guides
Chatbot for Laravel Website Owners: Add the Embed Script to Blade the Safe Way, With Config Caching, Logged-In Names and Test Routes (Free Copy-Ready Snippets)
Chatbot for Education Website: Which Questions to Automate, Which to Hand to Staff, and Which to Leave to Official Pages (Free Setup Quiz)
Chatbot for HTML Website Rollout: Get One Snippet onto Every Page and Prove It Works on All of Them
Add chat to your PHP site
One footer include, a free plan for two websites and no per-seat charges. Start free on livechatbot.in.