Skip to the page
Docs articles

Google Tag Manager

Add the widget to every page your Google Tag Manager container runs on, as a Custom HTML tag, test it in Preview, and fire it only once a visitor agrees.

Last updated

View as Markdown
On this page

If your site already runs a Google Tag Manager container, the widget can go in as a tag, with no change to your site's code.

Before you start

The tag

Tag Manager may refuse newer JavaScript in a Custom HTML tag, such as the arrow functions in the install guide's snippet, and handles the type of the scripts it adds in its own way. So paste this version instead. It does the same as the snippet, in older syntax, and adds the widget's script itself:

<script>
  window.$notert = window.$notert || [];
  window.notert = window.notert || new Proxy({}, {
    get: function (_, call) {
      if (typeof call != "string" || call == "then" || !/^[a-z]/i.test(call)) return undefined;
      return function () {
        window.$notert.push([call].concat(Array.prototype.slice.call(arguments)));
      };
    }
  });
  window.notert.init("YOUR_WORKSPACE_ID", { widget: true, theme: "page" });

  (function () {
    var src = "https://app.notert.io/embed/v1.js";
    if (document.querySelector('script[src="' + src + '"]')) return;
    var script = document.createElement("script");
    script.type = "module";
    script.async = true;
    script.src = src;
    document.head.appendChild(script);
  })();
</script>

Put your workspace's id in place of YOUR_WORKSPACE_ID. The options are those the install guide writes: for your own button rather than the round one, add launcher: false, and for another theme, set theme to "light", "dark" or "auto". Every option is in the JavaScript reference.

Add it to your container

  1. In Tag Manager, open your container, then Tags, and press New.
  2. Under Tag Configuration, choose Custom HTML and paste the tag above.
  3. Under Triggering, choose All Pages.
  4. Name the tag, such as Notert widget, and save it.
  5. Press Preview and open your site in the window it connects. Your site shows the round button once the page has loaded, and Tag Assistant lists Notert widget among the tags that fired.
  6. Back in Tag Manager, press Submit, then Publish, so the change reaches every visitor.
  7. Open a page of your site. Within moments, the install guide's Check it's live shows its address.

Calls from your site or other tags

The widget's own calls, such as identify for a signed-in user or context for what your page knows, can run from your site's code or from another tag once this one has fired, whether the widget has loaded yet or not: the tag keeps each call and the widget plays them back in order.

From another tag, set its tag sequencing, under Advanced Settings, to fire Notert widget first, or check window.notert exists before calling it. A token for identify must come from your server, never be signed in a tag: see sign a token on your server.

If your site uses Tag Manager's consent settings, you can hold the tag until a visitor agrees. Open the tag's Advanced Settings, then Consent Settings, choose Require additional consent for tag to fire, and add the consent type your banner uses for features like support chat, such as functionality_storage. The widget sets no cookies, and stores a key in the browser only once a visitor opens it; which category it belongs to is your call. See what the widget records about visitors.

If a visitor withdraws consent, the tag that already fired stays on the page until the next load. To take the widget off at once, run window.notert.shutdown({ forget: true }) from the tag your banner fires on withdrawal. See shutdown.

Content Security Policy

If your site sends a Content-Security-Policy header, it must let Tag Manager run its Custom HTML tags, which are inline scripts, and allow the widget's sources at https://app.notert.io. See Content Security Policy for the sources the widget needs.

Start here

Up and down arrowsto moveEnterto openEscto close