Databuddy Analytics
Databuddy is a privacy-first analytics platform focused on performance and minimal data collection.
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.
disabledbooleanDisable all tracking when set to `true`.
trackScreenViewsboolean = trueTrack screen/page views automatically.
trackPerformanceboolean = trueTrack page performance metrics.
trackSessionsboolean = trueTrack user sessions.
trackWebVitalsbooleanTrack Web Vitals (LCP, FID, CLS, etc.).
trackErrorsbooleanTrack JavaScript errors.
trackOutgoingLinksbooleanTrack outgoing link clicks.
trackScrollDepthbooleanTrack scroll depth.
trackEngagementbooleanTrack user engagement time.
trackInteractionsbooleanTrack user interactions (clicks, form submissions, etc.).
trackAttributesbooleanTrack element attributes for detailed interaction context.
trackHashChangesbooleanTrack hash changes in the URL.
trackExitIntentbooleanTrack exit intent behavior.
trackBounceRatebooleanTrack bounce rate metrics.
enableBatchingbooleanEnable event batching for better performance.
batchSizenumberMaximum number of events per batch.
batchTimeoutnumberTimeout (in ms) before flushing a batch.
enableRetriesbooleanEnable automatic retries for failed requests.
maxRetriesnumberMaximum number of retry attempts.
initialRetryDelaynumberInitial delay (in ms) before the first retry.
samplingRatenumberSampling rate (0 to 1). Set to `0.5` to track ~50% of sessions.
sdkstringCustom SDK identifier.
sdkVersionstringCustom SDK version string.
enableObservabilitybooleanEnable observability/monitoring features.
observabilityServicestringThe service name for observability reporting.
observabilityEnvironmentstringThe environment name for observability (e.g., `'production'`, `'staging'`).
observabilityVersionstringThe version string for observability reporting.
enableLoggingbooleanEnable console logging for debugging.
enableTracingbooleanEnable request tracing.
enableErrorTrackingbooleanEnable error tracking via observability.