Back to blog
June 3, 20255 min read

Embedding Your Chatbot on Any Website

Copy the embed snippet and add your PageGPT chatbot to any webpage in under 2 minutes.

Embedding Your Chatbot on Any Website

Once your chatbot is trained, you can embed it on any website with a single <script> tag.

Get the Embed Code

  • Open your chatbot and click the Embed tab.
  • Copy the script snippet shown.
  • It looks like this:

    <script
      src="https://pagegpt.tech/widget.js"
      data-chatbot-id="your-chatbot-id"
      defer
    ></script>
    

    Plain HTML Site

    Paste the snippet just before the closing </body> tag on every page you want the chatbot to appear:

    <!DOCTYPE html>
    <html>
      <head>...</head>
      <body>
        <!-- your page content -->
    
        <script
          src="https://pagegpt.tech/widget.js"
          data-chatbot-id="your-chatbot-id"
          defer
        ></script>
      </body>
    </html>
    

    The widget loads asynchronously so it never slows down your page.

    WordPress

    The easiest way is to add the snippet to your theme's footer so it appears on every page.

    Option A — Theme Editor (classic themes)
  • Go to Appearance → Theme File Editor in your WordPress dashboard.
  • Open footer.php.
  • Paste the snippet just before </body>:
  • <script
      src="https://pagegpt.tech/widget.js"
      data-chatbot-id="your-chatbot-id"
      defer
    ></script>
    
  • Click Update File.
  • Option B — Insert Headers and Footers plugin (recommended)
  • Install the free Insert Headers and Footers plugin.
  • Go to Settings → Insert Headers and Footers.
  • Paste the snippet in the Scripts in Footer box.
  • Save. Done — no theme editing required.
  • Option C — Block themes (Full Site Editing)
  • Go to Appearance → Editor → Templates → All Templates.
  • Open the template (e.g. Index or Single).
  • Add a Custom HTML block at the very bottom and paste the snippet.
  • Next.js

    Add the widget once in your root layout so it loads on every page.

    App Router (app/layout.tsx)
    import Script from "next/script";
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      return (
        <html lang="en">
          <body>
            {children}
            <Script
              src="https://pagegpt.tech/widget.js"
              data-chatbot-id="your-chatbot-id"
              strategy="lazyOnload"
            />
          </body>
        </html>
      );
    }
    
    Pages Router (pages/_document.tsx)
    import { Html, Head, Main, NextScript } from "next/document";
    import Script from "next/script";
    
    export default function Document() {
      return (
        <Html lang="en">
          <Head />
          <body>
            <Main />
            <NextScript />
            <Script
              src="https://pagegpt.tech/widget.js"
              data-chatbot-id="your-chatbot-id"
              strategy="lazyOnload"
            />
          </body>
        </Html>
      );
    }
    

    Always use Next.js <Script> (not a plain <script>) so Next.js can manage loading strategy correctly.

    Webflow

  • Go to Site Settings → Custom Code.
  • Paste the snippet in the Footer Code box.
  • Publish your site.
  • To add it to a single page only, open that page's settings and paste in the page-level Footer Code field instead.

    Shopify

  • In your Shopify admin go to Online Store → Themes → Edit Code.
  • Open layout/theme.liquid.
  • Paste the snippet just before </body>.
  • Save.
  • Wix

  • Go to Settings → Custom Code in your Wix dashboard.
  • Click + Add Custom Code.
  • Paste the snippet, set Place Code to Body - end, and choose whether to add it to all pages or specific ones.
  • Apply and publish.
  • Squarespace

  • Go to Website → Pages, then click the gear icon next to the page (or use Website → Settings → Advanced → Code Injection for site-wide placement).
  • Paste the snippet in the Footer field.
  • Save.
  • Allowed Domains

    To prevent unauthorized use of your chatbot, add your domain to the Allowed Domains list in the Embed tab. Requests from other domains will be blocked.

    Customizing the Widget

    You can change the chatbot's appearance in the Appearance tab:

    • Primary color — matches your brand
    • Bot icon — upload a custom avatar
    • Welcome message — the first message shown to visitors
    • Suggested questions — shown as quick-start buttons

    Ready to try PageGPT?

    Build your first AI chatbot in under 5 minutes. Free — no credit card needed.

    Get started free →