Install guides / Google Tag Manager

Add a support chat widget to Google Tag Manager

The Product.tech chat answers your visitors from your help center, hands the questions it can't answer to your team, and shows what's new. Here's where its line goes on Google Tag Manager.

Before you start

Copy your own line from your dashboard, on the Chat widget page. The examples here use acme-invoices, our demo product, so swap in yours. The button stays hidden until you publish an article, so it's safe to add the line first.

Add it to Google Tag Manager

  1. In Tag Manager, open your container and go to Tags, then New.
  2. Under Tag Configuration, choose Custom HTML and paste the snippet below, with your own product in place of acme-invoices.
  3. Under Triggering, choose All Pages.
  4. Save, then Submit and publish the container.

Custom HTML

<script>
  (function () {
    var script = document.createElement("script");
    script.src = "https://product.tech/widget.js";
    script.async = true;
    script.setAttribute("data-product", "acme-invoices");
    (document.body || document.head).appendChild(script);
  })();
</script>

Good to know

  • The snippet builds the script tag itself, so data-product reaches the widget however Tag Manager inserts it. Set any other option the same way, such as script.setAttribute("data-position", "left").
  • Anything that blocks Tag Manager, such as some ad blockers, blocks the chat too. If that matters for your visitors, put the line on the site itself.
  • If you list the sites allowed to show your chat, on the Chat widget page, add every address this site is served from, staging addresses included. With no list, any site can show it.

Check that it works

Use Preview in Tag Manager: the tag shows under Tags Fired on every page.

After publishing, open your site in a private window. The button appears in the bottom corner after a moment.

No button? Open the browser's console. A message starting with [product.tech] says what's wrong, such as a missing data-product or a site that isn't on your list of allowed sites. With nothing there, check that your help center has at least one published article.

Options

Add any of these to the line, next to data-product. Each one wins over what you picked on the Chat widget page.

data-position="left"
The corner for the button and the chat: left or right.
data-color="#0a7d5a"
The button's colour, as a hex value.
data-label="Need help?"
The button's words.
data-theme="dark"
Light, dark or system, which follows each visitor's device.

To open the chat from a link or button of your own, call ProductTechWidget.open().

Other platforms

New to Product.tech? It writes your help center from your live app, and from your code once you connect GitHub, then drafts release notes from merged pull requests. See how it works.

Add a support chat widget to Google Tag Manager · Product.tech