C15T Logo

Databuddy

Databuddy is a privacy-focused analytics platform that helps you understand user behavior and track events. It supports cookieless tracking and manages consent automatically through c15t's consent state synchronization.

The Databuddy script automatically respects consent preferences by toggling tracking on and off based on the user's consent state.

Script Implementation

Adding the Databuddy script to c15t

import { configureConsentManager } from 'c15t';
import { databuddy } from '@c15t/scripts/databuddy';

configureConsentManager({
  // ... 
  scripts: [
    databuddy({ 
      clientId: 'your-client-id',
      scriptUrl: 'https://cdn.databuddy.cc/databuddy.js',
      apiUrl: 'https://basket.databuddy.cc',
      options: {
        trackScreenViews: true,
        trackOutgoingLinks: true,
      }
    }),
  ],
});

Using Databuddy in your application

Once initialized, Databuddy is available globally via window.databuddy or window.db:

// Track a custom event
window.databuddy?.trackCustomEvent('button_clicked', {
  button_id: 'signup',
  page: '/landing'
});

// Or use the shorthand
window.db?.track('purchase_completed', {
  amount: 99.99,
  currency: 'USD'
});

// Track a screen view manually
window.databuddy?.screenView('/dashboard', {
  user_role: 'admin'
});

// Set global properties for all events
window.databuddy?.setGlobalProperties({
  app_version: '1.2.3',
  environment: 'production'
});

The Databuddy integration automatically handles consent management:

  1. Before Script Load: Sets window.databuddyConfig.disabled based on initial consent state
  2. On Consent Grant: Enables tracking by setting window.databuddy.options.disabled = false
  3. On Consent Revoke: Disables tracking by setting window.databuddy.options.disabled = true

This ensures that no tracking occurs without user consent, keeping your analytics privacy-compliant.

Configuration Options

The options parameter allows you to customize Databuddy's behavior:

databuddy({
  clientId: 'your-client-id',
  scriptUrl: 'https://cdn.databuddy.cc/databuddy.js',
  apiUrl: 'https://basket.databuddy.cc', // Optional, defaults to basket.databuddy.cc, change if self-hosting
  options: {
    // Tracking options
    trackScreenViews: true,        // Automatically track page views
    trackOutgoingLinks: true,      // Track clicks on external links
    trackAttributes: false,        // Track data-track attributes on elements
    trackErrors: false,            // Track JavaScript errors
    trackPerformance: true,        // Track performance metrics
    trackWebVitals: false,         // Track Core Web Vitals
  
    
    // Network options
    enableBatching: false,         // Batch events before sending
    batchSize: 10,                 // Events per batch
    batchTimeout: 2000,            // Batch timeout in ms
    samplingRate: 1.0,             // Sample rate (0.0-1.0)
  }
})

Types

DatabuddyConsentOptions

Property
Types

Script

Property
Types