# Add Asks with Google Tag Manager

> Load the Asks AI chat widget through Google Tag Manager with a Custom HTML tag that creates the embed script, fired on DOM Ready on every page.

To load the Asks AI chat widget with Google Tag Manager, create a **Custom HTML** tag that adds the Asks embed script with a few lines of JavaScript, fire it with a **DOM Ready** trigger on all pages, and publish the container. Don't paste the plain snippet into the tag: Tag Manager doesn't reliably keep custom `data-` attributes on the script tags it injects, and without `data-widget-key` the widget never starts.

## Before you start

- Google Tag Manager's container snippet is already on every page of your site.
- The Chat widget reads **Live** at [Channels → Chat widget](https://app.asks.app/channels/widget).

## Add the tag

<Steps>

<Step title="Copy your widget key">

Open [Channels → Chat widget → Deploy](https://app.asks.app/channels/widget/deploy), keep **Code snippet** and **HTML**, select **For website visitors without logins**, and copy the snippet. You need the value of its `data-widget-key` attribute.

<Frame src="/images/get-started/onboarding-step-go-live.png" alt="Onboarding Put it on your site step with the Embed Code card showing the script tag, including the data-widget-key value, and a Copy button, above the Installation status card" caption="Your widget key is the data-widget-key value in the snippet." />

</Step>

<Step title="Create a Custom HTML tag">

In Tag Manager, go to **Tags → New**, open **Tag Configuration**, and select **Custom HTML**. Paste this code and replace `YOUR_WIDGET_KEY` with your key:

```html
<script>
  (function () {
    var s = document.createElement("script");
    s.src = "https://cdn.asks.app/embed.js";
    s.async = true;
    s.setAttribute("data-widget-key", "YOUR_WIDGET_KEY");
    document.body.appendChild(s);
  })();
</script>
```

The code builds the same script tag as the Asks snippet, so the widget reads its key exactly as it would from your page. Leave **Support document.write** off.

</Step>

<Step title="Fire it on DOM Ready">

Under **Triggering**, add a new trigger, choose **DOM Ready** as the trigger type, and keep **All DOM Ready Events**. The widget attaches to the page body, which exists once the DOM is ready. Name the tag, for example "Asks chat widget", and save it.

</Step>

<Step title="Preview, then publish">

Select **Preview**, open your site in Tag Assistant, and check that the tag appears under the tags that fired. Then select **Submit** and **Publish**.

</Step>

</Steps>

## Verify it works

Open your site in a private window. The launcher appears in the bottom corner, and the Deploy tab's **Installation status** card reads "Widget detected on" followed by your domain. Send a test message: it lands in your [Inbox](https://app.asks.app/inbox), and the agent replies when it's on for the Chat widget at [AI agent → Deploy](https://app.asks.app/ai-agent/deploy).

<Frame src="/images/api/widget-identity-verification.png" alt="Chat widget Deploy tab scrolled to the Installation status card, which reads Widget detected on aurelia-skincare.com in green, between the server-side userHash code and the Identity verification (for users with logins) card" caption="Installation status turns green on the first page load with the widget." />

<Frame src="/images/ai-agent/deploy.png" alt="Deploy AI Agent page with the AI Agent Status card active and the Deploy to Channels card listing Chat widget switched on and Active, then WhatsApp Business, Instagram, Facebook Messenger, and Telegram with their own switches" caption="The agent answers on your site when Chat widget is on here." />

## Troubleshooting

### The tag fired, but there's no launcher

Open the browser console: the widget logs under an `[asks-widget]` prefix. A `404 Widget not found` on the config request means the key is wrong; a `400 Widget is not active` means the Chat widget or Spotlight isn't **Live**. A Content-Security-Policy error means your site needs the origins in the [Content-Security-Policy](/api/widget#content-security-policy) table.

### The widget loads only after visitors accept cookies

Your consent setup holds this tag until the visitor accepts a consent type the tag requires. Check the tag's consent settings in Tag Manager against how your privacy policy treats a support chat.

### The snippet is also in my site's code

Load the widget one way only. Remove either the tag or the snippet in your templates.

### Logged-in customers

Tag Manager can't sign user ids on your server. For verified, cross-device history, add the logged-in snippet to your site's templates, or call `window.AsksWidget.identify()` after login; see [Logged-in users](/api/widget#logged-in-users).

Google Tag Manager steps checked in November 2026 against Google's help article [Custom HTML tags](https://support.google.com/tagmanager/answer/6107167).

## Related

- Other ways to install: [HTML](/channels/widget/install/html), [WordPress](/channels/widget/install/wordpress), [React & Next.js](/channels/widget/install/react-nextjs), or [all install guides](/channels/widget/install).
- [Widget developer guide](/api/widget): every embed attribute and the JavaScript API.
- On asks.app: [the AI chatbot for websites](https://asks.app/ai-chatbot-for-website) and [the shared inbox](https://asks.app/shared-inbox) your team answers from.
