Getting Started

This guide takes you from a new Databuddy account to your first tracked page view.

Try Databuddy with Leap

Let Leap generate a complete application that uses Databuddy for analytics.

Examples:
1

Create Your Account

  1. Go to app.databuddy.cc
  2. Sign up for a free account
  3. Copy your Client ID from the dashboard
2

Install the SDK

Choose the install method for your app:

Install the official Databuddy SDK:

bash
# Using bun (recommended)
bun add @databuddy/sdk

# Using npm
npm install @databuddy/sdk

# Using yarn
yarn add @databuddy/sdk

For any website, use the script tag method:

html
<script
  src="https://cdn.databuddy.cc/databuddy.js"
  data-client-id="your-client-id"
  data-track-performance
  async
></script>
3

Add Tracking

Add the <Databuddy /> component once in your root layout:

app/layout.tsxtsx
import { Databuddy } from "@databuddy/sdk/react";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <head />
      <body>
        <Databuddy
          clientId={process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID!}
          trackPerformance
          trackWebVitals
          trackErrors
        />
        {children}
      </body>
    </html>
  );
}

Environment Variables:

.env.localbash
NEXT_PUBLIC_DATABUDDY_CLIENT_ID=your-client-id

Add the script to your HTML before the closing </body> tag:

index.htmlhtml
<!DOCTYPE html>
<html>
  <head>
    <title>My Website</title>
  </head>
  <body>
    <!-- Your content -->

    <!-- Databuddy Analytics -->
    <script
      src="https://cdn.databuddy.cc/databuddy.js"
      data-client-id="your-client-id"
      data-track-performance
      data-track-web-vitals
      data-track-errors
      async
    ></script>
  </body>
</html>
4

Verify Installation

Check that page tracking works:

  1. Visit your website in a new browser tab
  2. Open your Databuddy dashboard at app.databuddy.cc
  3. Check Real-time data - you should see yourself as an active visitor
  4. Navigate between pages - Databuddy records route changes automatically

Track Your First Custom Event

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

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

export function SignupButton() {
return (
  <button
    onClick={() =>
      track("signup_clicked", {
        location: "header",
        plan: "free",
      })
    }
    type="button"
  >
    Sign up
  </button>
);
}
index.htmlhtml
<script>
  function trackSignupClick() {
    db.track("signup_clicked", {
      location: "header",
      plan: "free",
    });
  }
</script>

<button onclick="trackSignupClick()">Sign up</button>

What's Next?

Troubleshooting

Not seeing data in your dashboard?

  1. Check your Client ID - Make sure it matches this website
  2. Test manually - Try db.track('test', {}) in your browser console
  3. Check Network tab - Look for requests to basket.databuddy.cc
  4. Review environment - Make sure tracking isn't disabled in production

How is this guide?