Integrations

Google Tag Manager

Load Databuddy from one Custom HTML tag, then send your data layer events to it.

Add the Databuddy tag

Add a Client ID variable

In Variables → User-Defined Variables, choose New → Constant. Name it Databuddy Client ID and paste the Client ID from your website's Settings → General in Databuddy.

Add a Custom HTML tag

Choose Add a new tag → Custom HTML, name it Databuddy - Analytics Script, and paste:

<script>
  (function () {
    var el = document.createElement("script");
    el.src = "https://cdn.databuddy.cc/databuddy.js";
    el.async = true;
    el.crossOrigin = "anonymous";
    el.setAttribute("data-client-id", "{{Databuddy Client ID}}");
    el.setAttribute("data-track-attributes", "true");
    el.setAttribute("data-track-errors", "true");
    el.onload = function () {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({ event: 'databuddy_ready' });
    };
    el.onerror = function () {
      console.warn('Databuddy script failed to load');
    };
    document.head.appendChild(el);
  })();
</script>

Set the trigger

Choose All Pages, or your consent manager's granted trigger if you need consent first. Under Advanced Settings → Tag firing options, choose Once per page.

Preview and publish

Choose Preview, visit your website and check the tag fires. Then Submit and Publish.

Pageviews, single-page app navigation and scroll depth are tracked automatically, so you don't need GA4-style page_view or scroll tags.

Databuddy loads after GTM, so window.databuddy doesn't exist yet when early tags fire. Fire event tags on the databuddy_ready Custom Event, or after it.

Send a data layer event

Create Data Layer Variables for the values, then fire a Custom HTML tag on the matching event:

Databuddy - Purchase
<script>
  if (window.databuddy) {
    databuddy.track("purchase", {
      transaction_id: "{{Transaction ID}}",
      value: {{Purchase Revenue}},
      currency: "{{Currency}}",
      item_count: {{Items Count}}
    });
  }
</script>

Quote text variables and leave number variables bare. The same pattern sends add_to_cart, begin_checkout or a form submit.

Track a click

Use a Click - All Elements trigger, for example where Click Classes contains track-button:

Databuddy - Button click
<script>
  if (window.databuddy) {
    databuddy.track("button_click", {
      button_text: "{{Click Text}}",
      page_path: "{{Page Path}}"
    });
  }
</script>

Use a Client ID per hostname

Make Databuddy Client ID a Lookup Table keyed by Page Hostname, with each hostname's Client ID, including staging. Add a trigger condition so the tag fires only on mapped hostnames, never with an empty Client ID.

Google's consent settings don't gate Databuddy on their own. Fire the tag from your consent manager's granted event, and set its additional consent checks.

WhenCall
Visitor withdraws consentwindow.databuddyOptOut(), and stop the tag firing again
Visitor grants it laterwindow.databuddyOptIn(), which doesn't override Global Privacy Control

How is this guide?