Skip to main content

Analytics

Databuddy

Configure Databuddy

Copy the client ID from your Databuddy project. The helper passes it to the script as data-client-id. Remove any existing Databuddy script and any code that sets window.databuddyConfig. The helper seeds that global only when it is absent, so an existing value overrides your initial state.

npm install @c15t/integrations@alpha
src/consent-scripts.ts
import { databuddy } from '@c15t/integrations/databuddy';

export const scripts = [
	databuddy({
		clientId: 'YOUR_CLIENT_ID',
		configWhenGranted: { disabled: false },
		configWhenDenied: { disabled: true },
	}),
];

Register the scripts

Complete your framework quickstart first. Keep its Inth endpoint, policy, styles and consent UI. Remove the vendor's original script, SDK initializer or tag-manager entry, so the vendor loads only through c15t.

The vendor pages put the helper in src/consent-scripts.ts. If your framework quickstart already has a scripts array, such as the one in c15t.config.ts in the Next.js guide, add the helper to that array instead of creating a second file. The scripts export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration point for your framework below. These are edits to that provider, not a second provider.

Add the configuration to scripts in c15t.config.ts, next to next.config.ts:

import { defineConsentConfig } from 'c15t/next';
import { scripts } from './src/consent-scripts';

export default defineConsentConfig({ scripts });

Keep the rest of your config, such as mode and routePrefix, in the same call. ConsentRoot reads the config in the browser, so the layout keeps passing only state. App Router, Pages Router and static export all read the same file. See Next.js scripts and embeds.

Options

OptionDefaultBehavior
clientIdRequiredSet as data-client-id. The helper trims it. Empty or whitespace-only values log an error and the script does not load.
configWhenGrantedRequiredObject set as window.databuddyConfig while measurement is allowed.
configWhenDeniedRequiredObject set as window.databuddyConfig while measurement is denied.
apiUrlhttps://basket.databuddy.ccCollection endpoint, set as data-api-url.
scriptUrlhttps://cdn.databuddy.cc/databuddy.jsLoader URL override. A blank value falls back to the default.

Loading and revocation

databuddy uses the measurement category with alwaysLoad, so the Databuddy script loads on every page, before the visitor chooses. Before the script loads, the helper sets window.databuddyConfig to configWhenDenied or configWhenGranted, unless that global already exists. After the script loads, the helper sets window.databuddy.options.disabled to true without measurement permission and to false with it. On each later consent change, the helper replaces window.databuddyConfig with the matching object and updates disabled again. c15t never removes the script.

The Databuddy SDK decides what disabled stops. The helper cannot prevent the script request before consent. If Databuddy must receive no request before consent, write a custom gated integration instead.

Verify Databuddy

  1. In a private window with an opt-in policy, load the page. databuddy.js loads from cdn.databuddy.cc with your data-client-id. In the console, window.databuddyConfig matches configWhenDenied and window.databuddy.options.disabled is true.
  2. Click Reject, then reload. disabled is still true, and DevTools Network shows no event request to your apiUrl.
  3. Open Privacy settings and allow measurement. Without a reload, disabled becomes false, window.databuddyConfig matches configWhenGranted, and event requests reach your apiUrl.
  4. Turn measurement off again and save. c15t reloads the page, and the new page starts with disabled set to true.

See the consent verification guide for navigation and hosting checks.