Skip to content

Installing the widget: one script tag, and the three things that trip people up

Adding Talk To My Sites is one line of HTML. Here's where it goes in plain HTML, Astro, Next.js and site builders, plus the domain, CSP and caching issues that cause most failed installs.

Talk To My Sites Team3 min read
A browser window with a chat bubble in the corner and a snippet sliding into place

The widget is a single script tag. It adds a chat bubble to the bottom corner of your pages and opens a chat panel when someone clicks it. There's nothing to build or bundle.

You'll find your snippet on your site page in the dashboard, in the Embed the widget card:

<script src="https://app.talktomysites.com/widget.js" data-site-id="YOUR_SITE_ID" defer></script>

The rule for every platform is the same: load it once, on every page. Paste it just before the closing </body> tag in whatever template or setting is shared across your site.

Plain HTML

Paste the snippet before </body> on each page, or in your shared footer include if you have one.

Astro

Add it to your base layout. Use is:inline so Astro leaves the tag alone instead of trying to bundle it.

<body>
  <slot />
  <script is:inline src="https://app.talktomysites.com/widget.js" data-site-id="YOUR_SITE_ID" defer></script>
</body>

Next.js

Add it to your root layout with next/script. The layout stays mounted between page changes, so the widget loads once.

import Script from "next/script";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script src="https://app.talktomysites.com/widget.js" data-site-id="YOUR_SITE_ID" strategy="afterInteractive" />
      </body>
    </html>
  );
}

Site builders and CMSs

Most builders have a setting for custom code in the site footer, or code added before </body> on every page. Paste the snippet there and publish. If the setting only applies to a single page, look for the site-wide version.

Pasting the snippet twice does no harm. Only the first copy runs.

The three things that trip people up

1. The widget domain doesn't match

Each site has one Widget domain, and the widget only answers there. That stops someone copying your snippet onto their own site.

example.com covers example.com and www.example.com. If your help pages live on docs.example.com, set the domain to *.example.com to cover every subdomain. localhost and 127.0.0.1 always work, so you can test locally.

If the bubble shows up but every question fails, check this first. Open Edit site and compare the widget domain with what's in your browser's address bar.

If the domain matches, check that it's verified. The widget only answers visitors once you've added the TXT record or meta tag shown in the Verify your domain to turn on the widget card and clicked Check now. The preview on your site page works before that, so a question can work there and fail on your site.

2. A Content Security Policy blocks it

If your site sends a Content Security Policy, allow https://app.talktomysites.com in script-src and connect-src. The widget adds its own styles, so style-src needs 'unsafe-inline'. Without that, the panel opens unstyled.

3. You changed the look but not the snippet

When you change the widget's appearance, the settings are written into the snippet as extra attributes. Copy the snippet again and replace the old one on your site. Suggested questions, the assistant's role and lead settings aren't in the snippet, so they don't need a new copy.

Check it works

Open a page on your site, look for the bubble and ask something your pages answer. If the bubble doesn't appear at all, view the page source and search for widget.js. If it's there but missing data-site-id, the browser console will say so.

That's the whole install. From there, the questions visitors ask start showing up in your dashboard.

More from the blog

Interlocking abstract blocks connected by thin lines, arranged around a central glowing cube.
Engineering5 min read

How TalkToMySites runs on Cloudflare

One Worker, a handful of bindings and no outside AI provider. A tour of the Cloudflare products behind TalkToMySites and what each one does.

A key resting in front of a closed gate, with a small glowing light on the gatepost.
Product5 min read

Why we ask you to verify your domain

Your site is indexed straight away, but the widget only answers visitors once you've proven the domain is yours. Here's what the step is and how it works.