How to Embed a Chatbot on Shopify (3 Methods)

Three ways to add a chatbot to your Shopify store — theme.liquid, a header/footer code app, or a theme app extension — plus PCI checkout rules and Knobot setup steps.

Which method should you use to embed a chatbot on Shopify?

Shopify gives you three practical paths. Editing theme.liquid is the most direct and works on every Shopify plan. A header/footer code app is the safest option for non-developers because it survives theme updates. Theme app extensions are the most robust long-term solution but require a Shopify Partner developer account and build tooling.

Shopify chatbot embed methods compared
MethodTechnical skillSurvives theme update?Page targeting?Best for
Edit theme.liquidBasic HTMLOnly if compatibleVia Liquid conditionalsDevelopers, hands-on owners
Header/footer code appNoneYesURL-pattern rules in app UINon-developers
Theme app extensionShopify CLI + Node.jsYes (native)App embed block settingsAgency builds, published apps

Method 1: How do you edit theme.liquid to add a chatbot?

Editing theme.liquid directly gives you full control and requires no third-party app. According to Shopify's theme code documentation, you should duplicate your theme as a backup before making any changes, because theme updates can remove manually edited code if they are incompatible.

  1. 1

    Back up your theme

    In your Shopify admin go to Online Store > Themes. Click the three-dot menu on your active theme and select Duplicate. This gives you a restore point.

  2. 2

    Open the code editor

    On your active theme, click the three-dot menu and select Edit code. The code editor opens with a file tree on the left.

  3. 3

    Open theme.liquid

    In the left sidebar, expand the Layout folder and click theme.liquid. This file wraps every page on your store.

  4. 4

    Paste the script tag before </body>

    Scroll to the bottom of the file and find the closing </body> tag. Paste your chatbot script tag immediately above it. Using async or defer keeps the script from blocking page render.

  5. 5

    Save and test

    Click Save (or press Ctrl+S / ⌘+S). Open your storefront in a new tab and confirm the chat widget appears.

The script placement matters. Putting the tag just before </body> means the page content loads first and the widget loads last, which is better for Core Web Vitals than placing it in <head>.

Method 2: How do you use a header/footer code app to embed a chatbot?

Several apps in the Shopify App Store let you inject scripts without touching theme files. The scripts are stored by the app independently of your theme, so they persist through theme switches and updates automatically. This is the recommended path for store owners who are not comfortable editing Liquid files.

  1. 1

    Install a header/footer code app

    Search the Shopify App Store for "Insert Header and Footer" or "Header Footer Code". Most have a free trial; paid plans start around $0.99–$2/month. Install the app and grant the permissions it requests.

  2. 2

    Open the app dashboard

    In your Shopify admin, go to Apps and click the app name. You will see input fields for Head code, Body start code, and Body end / Footer code.

  3. 3

    Paste your chatbot script into the Footer field

    Paste the chatbot script tag into the footer (body end) field. This loads the script after the page content, which is better for performance.

  4. 4

    Set page targeting if needed

    Most apps let you restrict the script to specific URL patterns. If you only want the widget on product pages, enter a URL rule like /products/. Leave blank for site-wide.

  5. 5

    Save and verify

    Save the settings and reload your storefront. The chat widget should appear on the pages matching your targeting rule.

Method 3: What is a Shopify theme app extension and when should you use it?

A theme app extension is the officially supported way for developers to add scripts to Shopify themes without modifying theme.liquid. As described in Shopify's developer documentation on app embed blocks, the extension creates an App Embed Block that merchants can toggle on or off from the theme editor — no code editing required on the merchant side. Scripts load natively and survive theme updates.

This method requires a Shopify Partner account, the Shopify CLI, and Node.js. It is appropriate when you are building a chatbot app for distribution on the App Store, or when an agency is implementing a custom solution for a client at scale. For a single-store embed, Methods 1 or 2 are faster.

  • App Embed Blocks load via Shopify's asset pipeline — no raw script tag required
  • Merchants toggle the integration on/off from the theme editor without touching code
  • Scripts survive theme switches because they live in the app, not the theme
  • Requires Shopify CLI, a Partner account, and a working knowledge of Node.js

How do you embed Knobot on a Shopify store?

Knobot provides a single <script> tag from its dashboard. You paste it into Shopify using Method 1 (theme.liquid) or Method 2 (a header/footer app) — no plugin or Shopify App Store listing required.

  1. 1

    Create and train your Knobot

    Sign in at knobot.org, create a new bot, and let it crawl your store URL. Knobot indexes your product descriptions, FAQs, and policy pages so it can answer pre-purchase questions accurately.

  2. 2

    Copy the embed snippet

    In the Knobot dashboard, go to Settings > Embed and copy the one-line script tag. It looks like: <script src="https://cdn.knobot.org/widget.js" data-bot-id="YOUR_ID" async></script>

  3. 3

    Add the snippet to theme.liquid or a code app

    Follow Method 1 or Method 2 above. Paste the Knobot script tag before </body> in theme.liquid, or into the Footer code field of your header/footer app.

  4. 4

    Configure lead-capture fields

    In the Knobot dashboard, set up what information the bot collects — name, email, or phone. Lead data routes to your email or an outbound webhook for CRM integration.

  5. 5

    Test on a real product page

    Open a product page and ask the bot a product question. Confirm it answers from your store content, not generic responses. If answers are wrong, edit the knowledge base in the dashboard.

Can you show the chatbot on product pages only?

Yes — and for many Shopify stores, page-specific targeting is the right default. A chatbot on a product page can answer "Does this come in size XL?" or "What is your return policy?" and capture the visitor's email before they leave. On the homepage or blog, the same widget may feel intrusive.

To target product pages only via theme.liquid, wrap the script in a Liquid conditional:

{% if template == 'product' %}
  <script src="https://cdn.knobot.org/widget.js" data-bot-id="YOUR_ID" async></script>
{% endif %}

Other useful Liquid template values: collection for collection pages, cart for the cart page, and page for static pages. If you use a header/footer code app, you can set URL targeting rules (for example, /products/ to match all product URLs) without touching Liquid.

Does adding a chatbot to your Shopify store affect conversion rates?

The conversion impact depends heavily on what the chatbot does and where it appears. A widget that answers real pre-purchase questions — sizing, shipping timeframes, material details — removes the friction that causes visitors to abandon product pages before adding to cart. A generic "How can I help you?" widget that cannot answer product questions adds noise without benefit.

The clearest opportunity is after-hours coverage. Most small Shopify stores cannot staff live chat in the evenings, but product pages receive traffic around the clock. A RAG-grounded chatbot that answers from your actual product and policy content can resolve visitor questions and capture contact details when no one is available to respond manually.

What does PCI compliance require for chatbot scripts on Shopify?

According to PCI DSS 6.4.3 guidance, requirement 6.4.3 was introduced to prevent e-skimming attacks (Magecart and similar) where malicious scripts intercept card data entered on checkout forms. The requirement does not ban all third-party scripts from checkout — it requires that any script present be documented, justified, and monitored. In practice, the safest approach for a small merchant is to keep chat widgets entirely off checkout pages, since there is little conversion benefit there anyway. Visitors who reach checkout have already decided to buy.

Shopify's hosted checkout is PCI-compliant by default. If you use Shopify Payments or another processor through Shopify, your checkout page is on a Shopify-controlled domain where you cannot inject arbitrary scripts. The risk is greatest for stores using custom checkout implementations or third-party payment gateways that redirect to pages you control.

What Shopify-specific gotchas should you watch for?

  • Theme update overwrites: Manually editing theme.liquid means updates may remove your script if there is a code conflict. Shopify recommends duplicating your theme before any code change. Use a code app if your theme updates frequently.
  • Theme inheritance: Shopify Online Store 2.0 themes (like Dawn) support app embed blocks natively. Older themes (like Debut) may not. Check your theme version before using Method 3.
  • App conflicts: Two chat widgets loading at once will both appear and fight for the bottom-right corner. If you have Shopify Inbox enabled, disable it on the pages where Knobot runs — or restrict Knobot to pages where Inbox is not active.
  • Script loading order: If you use a Consent Management Platform (CMP) for GDPR cookie consent, your chatbot script may need to load after consent is granted. Most CMP apps offer a "consent-gated" script loader — consult your CMP documentation.
  • Headless Shopify: Stores using a custom storefront (Next.js, Hydrogen, etc.) that bypass theme.liquid need to add the script tag inside their frontend component tree. Methods 1 and 2 do not apply.
  • CSP headers: Some Shopify themes or CDN configurations apply Content Security Policy headers that block unknown script sources. If your chat widget does not appear, open the browser console and look for CSP errors, then add the widget domain to your CSP allowlist.

Frequently asked questions

Will the chatbot work with my theme — Dawn, Debut, or a custom theme?

Yes. A plain JavaScript snippet injected into theme.liquid works regardless of which Shopify theme you use. The script loads after the HTML renders, so it is theme-agnostic. The only exception is heavily customised headless Shopify setups that bypass theme.liquid entirely — those require placing the script tag in your custom frontend layer.

Can I limit the chatbot to product pages only?

Yes. Inside theme.liquid you can wrap the script tag in a Liquid conditional — for example, {% if template == "product" %}. Header/footer code apps such as Insert Header and Footer support URL-pattern targeting without touching code. Either approach lets you restrict the widget to product, collection, or any specific page template.

Will the chatbot widget slow down my store?

A well-implemented chatbot script loads asynchronously and should add fewer than 100 ms to time-to-interactive on a typical connection. Shopify recommends loading third-party scripts with the async or defer attribute to avoid render-blocking. Knobot's embed snippet loads asynchronously by default.

Should the chatbot appear on my checkout page?

No. PCI DSS requirement 6.4.3 requires that every third-party script on a payment page be inventoried, justified, and monitored for integrity. Adding an unapproved chat widget to checkout increases your compliance burden with no meaningful conversion benefit — visitors are already committing to purchase. Keep the widget on marketing pages and the cart page only.

Which is safer — editing theme.liquid or using an app?

Apps are generally safer for non-developers because they keep your code changes separate from theme files. Shopify warns that theme updates can overwrite manually edited code if there are incompatibilities. A header/footer code app stores the script independently of the theme, so it survives theme updates and switches automatically.

How does a third-party chatbot interact with Shopify Inbox?

Shopify Inbox and a third-party chatbot like Knobot are independent widgets. Both can coexist on a store, but showing two chat icons at once can confuse visitors. Most merchants choose one. Knobot handles pre-purchase questions and lead capture; Shopify Inbox focuses on order-status and post-purchase support. If you use Shopify Inbox for fulfilment queries, you can run Knobot on product and landing pages only and disable it on the order-status page.

Sources