ReTarget.gg
Guides & recipes

Google Tag Manager recipe

Install ReTarget.gg on any site via Google Tag Manager in under a minute. One Custom HTML tag, one trigger, done.

3 min readReviewed Apr 27, 2026

If you manage your site's tags through Google Tag Manager, you can install ReTarget.gg without touching a single line of source code. One Custom HTML tag. One All-Pages trigger. Publish.

Public key + website key required

Install

  1. Open GTM → Tags → New → Custom HTML

    In your GTM workspace, create a new tag. Pick Custom HTML as the tag type.

  2. Paste the snippet

    This is the exact tag the dashboard generates. The guard on data-website makes it safe to fire on every page: the widget still loads exactly once per document, even after SPA route changes or GTM refire.

    GTM Custom HTML
    <script>
    (function () {
      if (document.querySelector('script[data-website="{{WEBSITE_KEY}}"]')) return;
      var s = document.createElement('script');
      s.src = 'https://cdn.retarget.gg/widget.js';
      s.async = true;
      s.setAttribute('data-pub', '{{PUBLIC_KEY}}');
      s.setAttribute('data-website', '{{WEBSITE_KEY}}');
      s.setAttribute('data-api', 'https://api.retarget.gg');
      (document.head || document.documentElement).appendChild(s);
    })();
    </script>

    Signed in?

    If you're logged into the dashboard, the snippet above already shows your real data-pub and data-website values. Copy it as-is: no placeholder substitution needed.

  3. Set the trigger to All Pages

    Under Triggering, pick All Pages (the built-in page-view trigger). Don't add a DOM-Ready or Window-Loaded trigger: the widget's guard handles the ordering.

  4. Save → Submit → Publish

    Name the tag something like ReTarget.gg widget. Click Save, then Submit your workspace as a new container version. Publish.

Verify

Open your site in a new tab with DevTools open:

  1. Network tab → filter for 'widget.js'

    You should see a 200 OK from https://cdn.retarget.gg/widget.js.

  2. Filter for 'api.retarget.gg'

    A GET /v1/decision should fire with a 200 response. Blocked visitors will see the overlay; allowed visitors see nothing (and a 204 No Content snippet-ping confirms the widget is alive).

  3. Preview mode (optional)

    In GTM, click Preview, open your site in the Tag Assistant flow, and confirm the ReTarget.gg widget tag shows as Fired on the first page view.

SPA / route-change sites

On SPAs the Custom HTML tag may refire when the History trigger fires. The querySelector('script[data-website="..."]') guard at the top of the snippet prevents a duplicate load: the widget runs exactly once per document, as designed.

Using a different container for the section widget

If you're installing the inline section widget instead of the default popup overlay, the tag is the same pattern: just swap the script URL and add data-container:

Section widget via GTM
<script>
(function () {
  if (document.querySelector('script[data-website="{{WEBSITE_KEY}}"]')) return;
  var s = document.createElement('script');
  s.src = 'https://cdn.retarget.gg/widget-section.js';
  s.async = true;
  s.setAttribute('data-pub', '{{PUBLIC_KEY}}');
  s.setAttribute('data-website', '{{WEBSITE_KEY}}');
  s.setAttribute('data-api', 'https://api.retarget.gg');
  s.setAttribute('data-container', 'retarget-ads');
  (document.head || document.documentElement).appendChild(s);
})();
</script>

You still need a <div id="retarget-ads"></div> somewhere in your page source: the widget mounts into the element by id. See Section widget integration for placement tips.

Troubleshooting

Tag fires but nothing loads

The most common cause is an origin mismatch: your site's domain isn't registered on the website in the dashboard. Check the browser console for [AF] decision failed · check domain + CORS. Add the correct domain under Websites → your site → Domain.

Popup never appears

Either your geo rules allow the current country (that's a success: the widget is silent), or the /v1/decision request is failing. Open Network, look at the response. If allowed: true, it's behaving correctly. See Debugging for the full decision tree.

Need help with setup?

Send us your website stack, target regions, and whether you are installing Geo Popup or Decline Popup.