Shopify Integration Guide
Add the Demeterics AI Chat widget to your Shopify store using the theme editor.
Requirements
- A Shopify store (any plan)
- A Demeterics AI Chat widget (get your widget key from the AI Chat dashboard)
- Staff access with permission to edit your theme
Important: Theme code does not run on Shopify's checkout, Thank you, or Order status pages. The widget will appear on your storefront — home, collection, product, cart, and page templates — but not during checkout.
Method 1: Edit theme.liquid (Recommended)
This method works site-wide across every storefront page.
Step 1: Get Your Widget Code
- Log into your Demeterics dashboard
- Go to AI Chat
- Click on your widget
- Copy your Agent Key (e.g.,
DEM-A4E4OWSVGHBN)
Step 2: Duplicate Your Theme (Recommended)
Shopify recommends backing up before editing theme code:
- From your Shopify admin, go to Online Store → Themes
- Find your live theme and click … → Duplicate
- Make your edits on the duplicate, then publish it once you've tested
This makes it easy to discard your changes and start again.
Step 3: Open the Code Editor
- From your Shopify admin, go to Online Store → Themes
- Find the theme you want to edit and click … → Edit code
- In the file list, open the Layout folder
- Click theme.liquid
Step 4: Add the Widget Code
- Scroll to the bottom of the file and find the closing
</body>tag - Paste this code just before
</body>:
<!-- Demeterics AI Chat Widget -->
<script src="https://demeterics.com/widget/embed.js?k=DEM-YOUR-KEY-HERE" async></script>
<dem-agent name="default" title="Need help?" state="minimized"></dem-agent>
- Replace
DEM-YOUR-KEY-HEREwith your actual Agent Key - Click Save
Why before </body>?: Your store's content loads first, so the widget never slows down your product pages.
Watch your quotes: If you retype the snippet, make sure it uses straight quotes ("), not curly quotes. Curly quotes will break the script tag.
Step 5: Test Your Widget
- Visit your live storefront (not the theme preview)
- The widget should appear in the bottom right corner
- Click it and send a test message
Method 2: Custom Liquid Section (No Code Editing)
If you'd rather not touch theme.liquid, you can add the widget to a specific page with a Custom Liquid section.
Limitation: This only applies to the template you add it to, not your whole store.
Steps:
- From your Shopify admin, go to Online Store → Themes
- Click Customize on your theme
- Navigate to the page or template where you want the widget
- Click + Add section
- Search for and select Custom Liquid
- Paste your widget embed code into the Custom Liquid field:
<script src="https://demeterics.com/widget/embed.js?k=DEM-YOUR-KEY-HERE" async></script>
<dem-agent name="default" title="Need help?" state="minimized"></dem-agent>
- Replace
DEM-YOUR-KEY-HEREwith your actual key - Click Save
Note: The floating widget positions itself in the corner of the viewport regardless of where the section sits on the page.
Customization Options
Change the Widget Title
<dem-agent name="default" title="Chat with us!"></dem-agent>
Use Different Prompts on Different Templates
If you've created multiple prompts in Demeterics (e.g., support, sales, product), you can pick one per template using Liquid in theme.liquid:
<script src="https://demeterics.com/widget/embed.js?k=DEM-YOUR-KEY-HERE" async></script>
{% if template contains 'product' %}
<dem-agent name="product" title="Product Questions?"></dem-agent>
{% elsif template contains 'cart' %}
<dem-agent name="checkout" title="Need help checking out?"></dem-agent>
{% elsif template contains 'index' %}
<dem-agent name="home" title="Welcome!"></dem-agent>
{% else %}
<dem-agent name="default" title="Need help?"></dem-agent>
{% endif %}
Make sure you've created these prompts (product, checkout, home) in your Demeterics dashboard first!
Start the Widget Open
<dem-agent name="default" title="Need help?" state="open"></dem-agent>
Embedded Widget (Inline on Page)
To place the widget inline (not floating), use a Custom Liquid section with:
<script src="https://demeterics.com/widget/embed.js?k=DEM-YOUR-KEY-HERE" async></script>
<dem-agent mode="embedded" name="support" title="Support Assistant"></dem-agent>
Troubleshooting
Widget doesn't appear
Check these:
- Did you click Save in the code editor?
- Are you editing the theme that's actually published? Edits to an unpublished theme only show in its preview.
- Is your widget key correct?
- Is your Shopify domain added to Allowed Domains in your Demeterics widget settings?
- Clear your browser cache and hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
Check the browser console (F12 → Console tab) for errors mentioning "demeterics".
"Domain not allowed for this agent"
- Go to your Demeterics dashboard → AI Chat → Your Widget
- Add your Shopify domain to Allowed Domains
- Built-in domain:
yourstore.myshopify.com - Custom domain:
yourstore.com(andwww.yourstore.com) - Add all of them if you use more than one
- Built-in domain:
- Save and refresh your storefront
Widget doesn't show during checkout
This is expected. Shopify's checkout, Thank you, and Order status pages don't run theme code, so no theme-installed widget appears there. Put your order, shipping, and returns information into your default prompt so shoppers can get those answers before they reach checkout.
Widget appears multiple times
If you added the code in more than one place:
- Check
theme.liquidfor a duplicate snippet - Check the theme editor for a leftover Custom Liquid section
- Keep the
<script src="...embed.js...">tag in exactly one place per page
Content Security Policy errors
Some themes and security apps add a restrictive Content Security Policy. If the console shows a CSP error blocking demeterics.com, add this near the top of the <head> in theme.liquid:
<meta http-equiv="Content-Security-Policy"
content="script-src 'self' https://demeterics.com; connect-src 'self' https://demeterics.com;">
If your theme already sets a CSP, extend the existing directive rather than adding a second one.
Changes disappeared after a theme update
If your code changes are incompatible with a theme update, Shopify removes them. Re-add the snippet to theme.liquid after any theme update, or use Method 2 so the widget lives in a section instead of the layout file.
Ecommerce Tips
Specialized prompts make a real difference on a storefront:
Product pages:
- Create a
productprompt with sizing, materials, and compatibility details - Target it with
{% if template contains 'product' %}
Cart and pre-checkout:
- Create a
checkoutprompt covering shipping times, rates, and returns - Target it with
{% if template contains 'cart' %}— remember the widget can't run on the checkout itself
General support:
- Use the
defaultprompt store-wide with your policies, contact details, and FAQ
Need Help?
Email us: support@demeterics.com
We can help with:
- Placing the snippet correctly in
theme.liquid - Choosing between theme code and a Custom Liquid section
- Writing product and shipping prompts for your store
- Troubleshooting CSP and theme conflicts
- Advanced widget customization