Skip to content
Guides7 min read

Add an AI assistant to WordPress, Webflow, Wix and more

Where to paste an AI assistant's embed snippet in WordPress, Webflow, Wix, Squarespace and Framer, plus Google Tag Manager, CSP settings and a test checklist.

ASDK TeamPublished 7 min read

On this page

TL;DR

  • Adding a website AI assistant is mostly a copy-and-paste job: one script tag, pasted once into the site-wide custom code field of your platform, then publish.
  • WordPress uses a plugin or a few lines in a child theme; Webflow, Wix, Squarespace and Framer each have a custom code setting, usually on paid plans.
  • Before you call it done, test on the published site, on mobile, and with your cookie and security settings switched on.

What you need before you start

  • The embed snippet from your assistant's dashboard, including your site ID.
  • Admin access to your website builder or CMS.
  • A plan that allows custom code. Most builders restrict it to paid plans or sites with a connected domain; details per platform are below.
  • Your domain on the assistant's allowed list. Many assistants only answer on domains you have approved, so add your production domain and any staging domain first.

An embed snippet for a website assistant usually looks like this. This one is ASDK's (ASDK is in early access); other vendors' snippets have the same shape:

HTML
<script async src="https://cdn.asdk.com/v1/asdk.js" data-site-id="site_XXXXXXXXXXXXXXXXXXXX"></script>

The async attribute matters. It tells the browser to download the script in parallel with the page and run it as soon as it is ready, instead of pausing page rendering (MDN). Because of it, the snippet can go in the head or just before the closing body tag without slowing the page down. Pick one location and add the snippet once; two copies usually mean two chat buttons.

WordPress

There are three ways in, from easiest to most controlled.

Option A: a plugin

ASDK's own WordPress plugin is coming soon. It will let you paste your site ID into a settings page instead of handling code. Until it is available, a general-purpose "header and footer code" plugin works: install one from the plugin directory, paste the snippet into its site-wide footer field and save.

On WordPress.com, installing plugins is available on all paid plans (Personal, Premium, Business and Commerce); free sites have to upgrade first (WordPress.com).

Option B: a few lines in a child theme

If you maintain a child theme or a site-specific plugin, enqueue the script the WordPress way. Since WordPress 6.3, wp_enqueue_script() accepts a loading strategy of async or defer and an in_footer flag (WordPress Developer Resources):

php
add_action( 'wp_enqueue_scripts', function () {
    wp_enqueue_script(
        'asdk-loader',
        'https://cdn.asdk.com/v1/asdk.js',
        array(),
        null,
        array( 'in_footer' => true, 'strategy' => 'async' )
    );
    wp_add_inline_script(
        'asdk-loader',
        'window.asdkConfig = { siteId: "site_XXXXXXXXXXXXXXXXXXXX" };',
        'before'
    );
} );

The inline script sets the configuration before the loader runs, so you don't need to add attributes to the script tag. Put this in a child theme's functions.php or a small custom plugin, never in a parent theme that updates will overwrite.

Option C: edit the theme template

Pasting the snippet directly into footer.php works on classic themes but breaks on the next theme update and doesn't exist on block themes. Prefer A or B.

Webflow

  1. Open Site settings and go to the Custom code tab.
  2. Paste the snippet into the Footer code field (it is added before the closing body tag) and save.
  3. Publish the site.

Webflow's custom code fields require a paid Site plan or a paid Workspace plan, and custom code runs only on the published site, not in the Designer (Webflow Help Center). Page-level code fields exist too, but use the site-wide field so the assistant appears on every page.

Wix

  1. In your site's dashboard, go to Settings.
  2. Under Development & integrations, click Custom Code, then + Add Custom Code.
  3. Paste the snippet and give it a recognizable name, such as "AI assistant."
  4. Choose All pages, then the load option your vendor recommends. If the chat button disappears when you move between pages, switch to loading the code on each page.
  5. Under Place Code in, choose Body – end, then click Apply.

Wix requires the site to be published and to have a connected domain before you can add custom code. Snippets are tied to that domain: if you assign a different domain to the site, Wix deletes them, so re-add the snippet after any domain change (Wix Help Center).

Squarespace

  1. Open the Code Injection panel (under Website Tools).
  2. Paste the snippet into the Footer field. Code there is added before the closing body tag on every page of the site.
  3. Click Save.

Code injection is available on Squarespace's Core, Plus and Advanced plans and some legacy plans, and checkout pages don't support code (Squarespace Help Center). If a script ever breaks the editor, Squarespace lets you add /safe after /config in the editing URL to load the editor with custom scripts turned off.

Framer

  1. Open your project and go to Site Settings → Code (Framer Help).
  2. Add a custom code entry with the snippet.
  3. Set Pages to All and Run to Once.
  4. Choose a placement. Framer can insert code at the start or end of the head or the body (Framer Developers); the end of the body is a good default for a chat widget.
  5. Publish and test on the live site.

Google Tag Manager

If marketing scripts on your site go through Google Tag Manager, the assistant can too. ASDK's Google Tag Manager template is coming soon; until then, use a Custom HTML tag.

Tag managers inject the script themselves, so they can't add the data-site-id attribute. Set a small configuration object first and then load the script:

HTML
<script>
  window.asdkConfig = { siteId: "site_XXXXXXXXXXXXXXXXXXXX" };
</script>
<script async src="https://cdn.asdk.com/v1/asdk.js"></script>
  1. In GTM, click Tags → New → Tag Configuration → Custom HTML (Tag Manager Help).
  2. Paste the code above.
  3. Set the trigger to All Pages (or Initialization – All Pages).
  4. Preview, then publish the container.

Google notes that "the best way to avoid performance and malware issues is to use the tag templates built into Tag Manager." Custom HTML is fine for a vendor you trust; a gallery template, when available, is the cleaner long-term option.

If your site uses a consent tool with Tag Manager, decide whether the assistant needs consent before it loads in your markets, and set the trigger accordingly. The privacy guide for AI chat explains when chat storage counts as strictly necessary.

Choosing where the assistant appears

Site-wide is the right default, but a few pages are better without a chat button:

  • Checkout, payment and login pages. Visitors there are finishing a task; an extra button competes with it. Squarespace doesn't run injected code on checkout pages anyway.
  • Pages with their own sticky call to action, such as a full-screen booking calendar, where two floating buttons would overlap.
  • Internal or test pages that shouldn't produce conversations.

Every platform above offers a way to narrow it down: Wix lets you choose specific pages, Webflow and Squarespace have page-level code fields, Framer entries can target pages, and on WordPress the enqueue function can check the current page before loading. Exclude pages rather than adding the snippet page by page, so new pages get the assistant automatically.

Content Security Policy: the setting that silently blocks widgets

If your site sends a Content-Security-Policy header, the browser only loads scripts and makes network requests to sources the policy allows (MDN). A blocked widget fails without any visible error on the page; the browser console shows it.

For ASDK, the script comes from cdn.asdk.com and the conversation goes to api.asdk.com, so the policy needs both:

Text
Content-Security-Policy: script-src 'self' https://cdn.asdk.com; connect-src 'self' https://api.asdk.com

Merge these into your existing policy rather than replacing it, and check your vendor's documentation for the exact hosts if you use a different assistant.

Test before you announce it

Check the published site, not the editor

Most builders don't run custom code in the editor or preview. Open the live URL in a private window.

Check every kind of page

Home, a blog post, the pricing page and a long landing page. A site-wide snippet should appear on all of them, once.

Check mobile

Make sure the chat button doesn't cover a cookie banner, a sticky "Book a demo" button or the navigation, and that the chat opens full-screen and closes cleanly.

Check the console

Open the browser's developer tools. Errors mentioning Content Security Policy, a blocked domain or a missing site ID point straight at the fix.

Ask real questions

Ask five questions you know the answers to, including one about pricing and one your site does not answer. The first tests the assistant's knowledge base; the last tests whether it admits it doesn't know.

Check speed and keyboard access

Run a Lighthouse report before and after; an async widget should barely move the numbers. Then reach the chat button with the Tab key and open it with Enter.

Troubleshooting

SymptomLikely causeFix
No chat button anywhereSite not republished, or code in a page-level fieldPublish; move the snippet to the site-wide field
Button on some pages onlySnippet added per page, or excluded templatesUse the site-wide field; check page exclusions
Two chat buttonsSnippet added twice (theme plus plugin, or GTM plus builder)Keep one installation
Button shows, no answersDomain not on the assistant's allowed listAdd the domain, including the www version if used
Console mentions Content Security PolicyPolicy blocks the script or the APIAllow the vendor's script and API hosts
Works on staging, not on productionDifferent domain, or Wix snippet removed after a domain changeAdd the production domain; re-add the snippet

Installation is half the job

The script makes the assistant appear. What it says depends on the content it learns from, so make sure your important pages are reachable and readable: no key facts locked inside images or PDFs, no pages blocked by mistake. The guide to training an assistant on your website covers preparing that content, and the agent-ready checklist covers making the same pages readable for outside AI agents, including an llms.txt file. An AI agent on your site and the assistants your buyers use elsewhere both depend on the same clear, current pages.

ASDK agentEarly access

Try the Chat agent in early access

Answers visitors from your own content, 24/7, and captures contacts.

On every platform here, the steps are the same: paste one snippet in the site-wide code field, publish, and test on the live site. Ten minutes of testing on mobile, with your consent banner and security policy switched on, catches nearly every problem before a visitor does.

Frequently asked questions

Do I need a developer to add an AI assistant to my website?

Usually not. On most website builders you paste one line of code into a site-wide custom code field and publish. A developer helps only if your site has a strict Content Security Policy or a custom theme you can't edit.

Should the snippet go in the head or before the closing body tag?

Either works for a script loaded with the async attribute, because it downloads without blocking the page. Before the closing body tag is a safe default. What matters most is adding it once, site-wide.

Can I add an AI chat widget with Google Tag Manager?

Yes, with a Custom HTML tag that fires on all pages. Tag managers can't add data attributes to the script they inject, so pass settings in a small configuration object set before the script loads.

Why doesn't the chat appear after I added the code?

Most often the site wasn't republished, the code went into a page-level field instead of the site-wide one, a security policy blocks the script, or your domain isn't on the assistant's allowed list.

Sources

Pages we read for this article, with the date we checked each one.

  1. wp_enqueue_script() — WordPress Developer Resources — accessed October 20, 2026
  2. WordPress plugins — WordPress.com Support — accessed October 20, 2026
  3. Custom code in head and body tags — Webflow Help Center — accessed October 20, 2026
  4. Wix Editor: Embedding custom code on your site — Wix Help Center — accessed October 20, 2026
  5. Using code injection — Squarespace Help Center (updated September 2026) — accessed October 20, 2026
  6. Add Google Tag Manager to your site — Framer Help — accessed October 20, 2026
  7. Custom code — Framer Developers — accessed October 20, 2026
  8. Custom tags — Tag Manager Help — accessed October 20, 2026
  9. The script element — MDN Web Docs — accessed October 20, 2026
  10. Content Security Policy (CSP) — MDN Web Docs — accessed October 20, 2026

Glossary terms in this article