NudgeDocs

Install with Google Tag Manager

Deploy the Nudge widget with a Custom HTML tag firing on all pages, without touching your site's code.

When to use Google Tag Manager

If Google Tag Manager (GTM) is already on every page of your site, you can deploy the widget from GTM instead of editing the site. The snippet is the same; GTM adds it to each page when it loads.

Install the widget

Copy your snippet

In Nudge, go to Agents › Website Agent › On your site › Copy the snippet, or open Settings › Integrations › Website › Google Tag Manager.

<script src="https://app.asknudge.ai/widget/loader.js"
  data-org="your-workspace"
  data-form="your-form" async></script>

Create a Custom HTML tag

  1. In your GTM container, go to Tags › New.
  2. Name it, for example "Nudge widget".
  3. Choose the Custom HTML tag type and paste the snippet as is.

Fire it on all pages

Under Triggering, choose All Pages. Save the tag.

Publish the container

Click Submit, then Publish. Tags only run on your site once the container version is published. GTM's Preview mode lets you test before publishing.

Check

Open a page of your site, then in Nudge click Re-check installation. See Verify the installation.

What changes with GTM

  • The install check cannot see the code in your HTML. GTM adds the snippet in the browser, after the page loads. When Nudge reads your page, it says the code is not in the HTML: with GTM, that is expected. Open a page of your site once, then re-check: the status turns Live as soon as the widget has loaded on a real page.
  • Cookie consent. If your GTM setup waits for consent before firing tags, the widget only loads for visitors who accepted. You can also fire the tag on all pages and let Nudge handle consent: see below.
  • Content Security Policy. If your site's policy uses 'strict-dynamic', Nudge cannot tell from the HTML whether GTM is allowed to load the snippet. Check the browser console on your site. See Content Security Policy.

In the form's widget settings (Forms › your form › Share), the Wait for cookie consent option keeps the widget hidden until the visitor has given consent. With this option on, tell the widget when consent is given, from your consent tool or a GTM tag that fires after consent:

<script>
  // The widget is already loaded: tell it now.
  if (window.Nudge) window.Nudge.setConsent(true);
  // Not loaded yet: it reads this value when it starts.
  else window.__nudge_consent = true;
</script>

Until then, the widget does not show, does not set its visitor cookie, and does not report the page view. The install status therefore stays Not detected until a visitor (you, for example) accepts cookies on a page.

Troubleshooting

On this page