Quickstart

Add Databuddy to your website and see your first visitor in two minutes.

  1. Add a website
  2. Add the snippet
  3. Deploy
  4. See visitors live

Add a website

Sign up at app.databuddy.cc and add your website. Copy its Client ID.

Add Databuddy

npm install @databuddy/sdk
app/layout.tsx
import { DatabuddyProvider } from "@databuddy/sdk/react";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <DatabuddyProvider clientId={process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID!} />
        {children}
      </body>
    </html>
  );
}
.env.local
NEXT_PUBLIC_DATABUDDY_CLIENT_ID=your-client-id

Deploy and check

Open your live website, then the dashboard: you appear as an active visitor within seconds. Route changes are tracked automatically.

Visits from localhost aren't sent. To test locally, add debug to the provider, or load databuddy-debug.js instead of databuddy.js, on a separate test website.

Track a custom event

components/signup-button.tsx
"use client";

import { track } from "@databuddy/sdk";

export function SignupButton() {
  return (
    <button onClick={() => track("signup_clicked", { plan: "free" })} type="button">
      Sign up
    </button>
  );
}

Keep event names stable and put details in properties.

Turn on errors and Web Vitals

<DatabuddyProvider
  clientId={process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID!}
  autocapture={{ webVitals: true, errors: true }}
/>

Error tracking needs the Hobby plan or higher. Add source maps to see your original code in stack traces.

No data?

CheckHow
The Client ID matches this websiteCompare it with the website's tracking setup in the dashboard
Events leave the browserNetwork tab: requests to basket.databuddy.cc
The tracker loadedConsole: db.track('test', {}) runs without an error

How is this guide?