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 routes all traffic through your domain for improved privacy and ad blocker bypass.
export default defineNuxtConfig({
scripts: {
firstParty: true,
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'
})