Scripts

Databuddy Analytics

Databuddy is a privacy-first analytics platform focused on performance and minimal data collection.

Databuddy Analytics

View source

Nuxt Config Setup

The simplest way to load Databuddy Analytics globally in your Nuxt App is to use Nuxt config. Alternatively you can directly use the useScriptDatabuddyAnalytics composable.

export default defineNuxtConfig({
  scripts: {
    registry: {
      databuddyAnalytics: {
        clientId: 'client-abc123'
      }
    }
  }
})

useScriptDatabuddyAnalytics()

The useScriptDatabuddyAnalytics composable lets you have fine-grain control over when and how Databuddy Analytics is loaded on your site.

const { proxy } = useScriptDatabuddyAnalytics()

proxy.track('conversion', { value: 1 })

Please follow the Registry Scripts guide to learn more about advanced usage.

First-Party Mode

This script supports First-Party Mode which is auto-enabled, routing all traffic through your domain for improved privacy and ad blocker bypass.

export default defineNuxtConfig({
  scripts: {
    registry: {
      databuddyAnalytics: {
        clientId: 'client-abc123'
      }
    }
  }
})

Example

Using Databuddy Analytics only in production while using the proxy to send events.

<script setup lang="ts">
const { proxy } = useScriptDatabuddyAnalytics()

// noop in development, ssr
// just works in production, client
function handleAction() {
  proxy.track('conversion', { value: 1 })
}
</script>

<template>
  <div>
    <button @click="handleAction">
      Send Event
    </button>
  </div>
</template>

CDN / Self-hosted

By default the registry injects https://cdn.databuddy.cc/databuddy.js. If you host the script yourself, pass scriptUrl in options to override the src.

useScriptDatabuddyAnalytics({
  scriptInput: { src: 'https://my-host/databuddy.js' },
  clientId: 'YOUR_CLIENT_ID'
})
clientIdstring required

Your Databuddy client ID.

scriptUrlstring = 'https://cdn.databuddy.cc/databuddy.js'

Custom script URL for the Databuddy SDK.

apiUrlstring = 'https://basket.databuddy.cc'

Custom API URL for sending analytics data.

disabledboolean

Disable all tracking when set to `true`.

trackScreenViewsboolean = true

Track screen/page views automatically.

trackPerformanceboolean = true

Track page performance metrics.

trackSessionsboolean = true

Track user sessions.

trackWebVitalsboolean

Track Web Vitals (LCP, FID, CLS, etc.).

trackErrorsboolean

Track JavaScript errors.

trackOutgoingLinksboolean

Track outgoing link clicks.

trackScrollDepthboolean

Track scroll depth.

trackEngagementboolean

Track user engagement time.

trackInteractionsboolean

Track user interactions (clicks, form submissions, etc.).

trackAttributesboolean

Track element attributes for detailed interaction context.

trackHashChangesboolean

Track hash changes in the URL.

trackExitIntentboolean

Track exit intent behavior.

trackBounceRateboolean

Track bounce rate metrics.

enableBatchingboolean

Enable event batching for better performance.

batchSizenumber

Maximum number of events per batch.

batchTimeoutnumber

Timeout (in ms) before flushing a batch.

enableRetriesboolean

Enable automatic retries for failed requests.

maxRetriesnumber

Maximum number of retry attempts.

initialRetryDelaynumber

Initial delay (in ms) before the first retry.

samplingRatenumber

Sampling rate (0 to 1). Set to `0.5` to track ~50% of sessions.

sdkstring

Custom SDK identifier.

sdkVersionstring

Custom SDK version string.

enableObservabilityboolean

Enable observability/monitoring features.

observabilityServicestring

The service name for observability reporting.

observabilityEnvironmentstring

The environment name for observability (e.g., `'production'`, `'staging'`).

observabilityVersionstring

The version string for observability reporting.

enableLoggingboolean

Enable console logging for debugging.

enableTracingboolean

Enable request tracing.

enableErrorTrackingboolean

Enable error tracking via observability.