Skip to content
AnswerWeaveStart free

Add a chat widget with Google Tag Manager

Install an AI assistant through a GTM Custom HTML tag — for Gamma and any platform with no HTML field. Why Save is not Publish, and the trigger to use.

Time
15–20 minutes
Coding needed
None
Paste it
Once, site-wide
Ongoing edits
None

What usually goes wrong

Three things account for nearly every failed install. All three are easy to avoid and hard to diagnose afterwards, so they are here rather than buried in troubleshooting.

The key in the snippet on screen is masked

The snippet shows the key as publishable_••••• — the prefix and dots, not the key. Paste that and every message the assistant tries to send is rejected. The full key is shown once, at the moment it is created or regenerated. If nobody kept it, use Regenerate and copy the new one immediately.

Paste it once, into a shared template

It belongs in the layout every page renders. Pasted into one page it appears on that page only; pasted into two places it loads twice and you get two chat bubbles.

Saving is not always publishing

Most platforms need a second action before the change is public — Publish on Webflow, Save on the live theme in Shopify, a cache purge on WordPress. If the snippet is definitely in place and the bubble is missing, this is usually why.

What you’ll need

  • Access to edit your site's template or custom-code settingsThe exact field differs per platform and is named on this page.
  • Permission to publish the siteOn most platforms an editor can save a draft but not release it.
  • The assistant's snippet and full publishable keyBoth come from one screen in AnswerWeave.
  • Every hostname the site answers onThe live domain, the www form if you serve it, and your platform's own preview address while you test.

Where everything lives

Everything you need on the AnswerWeave side is on a single screen. Open it once and you can finish the first three steps without navigating away.

Botsyour assistantWidget Install
  • General
  • Look & Behavior
  • Notifications
  • Widget Install
  • Advanced
  1. 1API key configured The current key, and the Regenerate button that reveals a fresh one.
  2. 2Restrict where this key works The domain list, with Add another domain and Add domain.
  3. 3Copy the embed snippet The snippet, with a Copy button, and your bot ID already inside it.
  4. 4Preview the widget Open preview, which runs the real assistant with no site key involved.

The procedure

  1. 1

    Get a key you can actually use

    Look at API key configured. If you still have the full publishable_… string from when this assistant was set up, use it and skip ahead. If all you can see is publishable_•••••, the key is masked and cannot be recovered — you need a new one: click Regenerate and copy the key immediately, because it is displayed once and never again.

    Regenerating invalidates the old key at once

    Any site already running on the previous key stops being served the moment you regenerate. If this assistant is live somewhere else, plan to update that install in the same sitting. Your domain restrictions carry over automatically — you do not have to set them again.
  2. 2

    Restrict where the key works

    The key is public — it has to be, because it runs in your visitor’s browser. What stops anyone else reusing it is this list, and a brand-new key allows every origin until you fill it in. Type a hostname into Add another domain, bare hostname only, then click Add domain. Repeat for every hostname the site answers on.

    Exact hostnames only — subdomains are separate entries

    example.com does not cover www.example.com, and there are no wildcards. Ports and paths are ignored, and localhost is fine for testing.

    While testing on Google Tag Manager, also allow

    • your-site.gamma.site — The Gamma-hosted address, if you are testing there before connecting your own domain.
  3. 3

    Copy the snippet

    Under Copy the embed snippet, click Copy. It comes out with your own bot ID already in place. Then replace the masked data-api-key value with the real key from step 1 — that is the only edit the snippet needs.

    Custom HTML tag contents
    <script>
    (function () {
      var ORIGIN = 'https://app.answerweave.ai';
    
      // Open the network connection early, so the assistant's first
      // request is not waiting on DNS and TLS.
      var preconnect = document.createElement('link');
      preconnect.rel = 'preconnect';
      preconnect.href = ORIGIN;
      preconnect.crossOrigin = 'anonymous';
      document.head.appendChild(preconnect);
    
      var s = document.createElement('script');
      s.src = 'https://app.answerweave.ai/widget/widget.js';
      s.async = true;
      s.setAttribute('data-bot-id', 'YOUR_BOT_ID');
      s.setAttribute('data-api-key', 'YOUR_PUBLISHABLE_KEY');
      s.setAttribute('data-api-url', ORIGIN);
    
      // This tag can fire before <body> exists. Appending to whichever
      // container is available is what stops it throwing on early loads.
      (document.body || document.head || document.documentElement).appendChild(s);
    })();
    </script>
  4. 4

    Paste it into Google Tag Manager

    Where: Tag Manager → Tags → New → Custom HTML

    1. Sign in at tagmanager.google.com and open the container for this website.
    2. In the left menu choose Tags, then New.
    3. Click the Tag Configuration panel and pick Custom HTML from the list that slides in.
    4. Name the tag something a colleague will recognise later, such as AnswerWeave assistant.
    5. Paste the block below into the HTML field and replace the two placeholders. Nothing else belongs in that field.
    6. Under Triggering, choose Initialization – All Pages. If your container does not offer it, All Pages is fine. Click Save.
    7. Submit, name the version, then Publish. Until the version is published the tag exists only in your draft workspace.

    Saving a tag does not put it live. In Tag Manager, Save stores your work in a draft workspace. Nothing reaches the website until you Submit and then Publish the container. A tag that looks finished in GTM and invisible on the site is almost always this.

    On Gamma, connect the container to the site. Copy the container ID (GTM-XXXXXXX), open the site in Gamma → the menu → Settings, paste it into the Google Tag Manager field, and Publish the Gamma site. The field is plan-dependent — confirm it exists before booking time for the rest.

    Either trigger works. The script appends to the head when the body is not ready yet, so firing early is safe.

    If a label does not match, Google Tag Manager Help is the authority — not this page.

Confirm it worked

Do all four. The first two prove the snippet is live; the third proves the key is accepted; the fourth proves the assistant is behaving as it should.

Test it before touching your website

Preview the widgetOpen preview runs the real assistant against your real content, with no site key involved. Settle the greeting, colour and answers there first, so that when you edit your site the only thing being tested is the install. Preview chats use real AI responses and are billed as normal, but they are kept out of your analytics, leads and usage, and are not saved as conversations.
  1. 1

    The launcher appears

    Open the live site in a private window — not the platform’s editor. The chat bubble should appear in the corner within a second or two.

  2. 2

    Exactly one launcher

    Two bubbles means the snippet is in two places. Find the second copy before going any further.

  3. 3

    The conversation reaches the dashboard

    Ask something your site covers, then find your test under the assistant’s conversations. That is end-to-end proof, not just a widget that rendered.

  4. 4

    It declines something you never published

    Ask a question your content does not cover. It should say so and offer to pass the question on, with no sources underneath. That behaviour is the product working, not failing.

If something is wrong

What you seeAlmost alwaysFix
No bubble on the live siteThe change was saved but not published, or a cache is still serving the old pagePublish the site, purge the cache and CDN, then reload in a private window
Bubble missing in the platform's editor or previewExpected. Most platforms do not run custom code inside their own editorCheck the live URL in a normal browser tab instead
Bubble opens, every message failsThe masked key was pasted, or this hostname is not on the restriction listPaste the full key, and add the exact hostname under Restrict where this key works
Works on example.com, refuses on www.example.comExact-match restriction — there are no wildcardsAdd the www hostname as its own entry
Two bubblesThe snippet is in two places — a theme file and a plugin, or a page as well as the layoutKeep one copy. Search the theme and any code-injection fields for a second one
It answers, but says almost everything is not coveredLittle or no indexed content — the crawl has not finished, or it failedCheck Sources, re-run the sync, then test again
It stopped working after someone regenerated the keyThe snippet on the site still carries the old keyUpdate data-api-key in the snippet, then save and publish again
Bubble shows in GTM Preview but not on the live sitePreview runs your draft workspace; the live site runs the published versionSubmit then Publish in Tag Manager
Console error about appending to nullAn older copy of the script that appends straight to document.bodyReplace the tag contents with the block on this page

Why the key is public, what someone can actually do with a copy, and the four-step test that tells you whether yours is restricted — we wrote it all down.

Paths on this page were last checked against Google Tag Manager on . If a label does not match what you see, the vendor’s own help centre is the authority.