---
title: "Privacy-fokussierte Analytics mit Tinybird in Astro einrichten"
description: "Echtzeit-Analytics ohne Cookies in Ihrer Astro-App mit Tinybird. Komplette Analytics-Plattform in Minuten deployen, ohne Third-Party-Tracking."
source: "https://www.launchfa.st/de/blog/setup-tinybird-analytics-astro"
author: "Rishi Raj Jain"
created_at: 2025-12-05T12:00:00.000Z
keywords: "astro, tinybird, analytics, privacy, web analytics, real-time analytics, clickhouse"
---

> **Site index for agents**
> Fetch https://www.launchfa.st/llms.txt to discover every page on this site.
> Every page is also available as Markdown by appending `.md` to its URL.

<img width="1600" height="900" alt="Setting Up Privacy-Focused Analytics with Tinybird in Astro" decoding="async" loading="eager" class="mt-4 border rounded-sm bg-cover bg-center bg-no-repeat transform will-change-auto" src="https://ik.imagekit.io/vjeqenuhn/launchfast-website/setup-tinybird-analytics-astro.png" />

Klassische Analytics wie Google Analytics bringen Nachteile: Datenschutz, GDPR, langsame Seiten durch Third-Party-Skripte, Datenhoheit. **[Tinybird](https://www.tinybird.co/)** ist privacy-fokussiert: Echtzeit-Analytics ohne Cookies, auf Ihrer Infrastruktur, powered by ClickHouse.

In dieser Anleitung richten Sie Tinybird mit dem Web-Analytics-Template ein und binden das Tracking-Skript in Astro ein.

## Voraussetzungen

- [Node.js 20](https://nodejs.org/en/blog/announcements/v20-release-announce) oder höher
- Ein [Tinybird](https://www.tinybird.co/)-Konto

## Tinybird-Workspace einrichten

Authentifizieren und Workspace wählen oder anlegen:

```bash
# (macOS/Linux) Tinybird CLI installieren
curl https://tinybird.co | sh

# (Windows) Tinybird CLI installieren
# powershell -ExecutionPolicy ByPass -c "irm https://tinybird.co | iex"

# Bei Tinybird anmelden (Browser)
tb login

# Workspace wählen oder erstellen
# Region nahe an Ihren Nutzern wählen
```

Nach der Anmeldung sehen Sie Workspaces oder werden zum Anlegen aufgefordert.

## Web-Analytics-Template deployen

Tinybird liefert ein Template mit Data Sources, Pipes und Endpoints:

```bash
# Web Analytics Template deployen
tb --cloud deploy \
--template https://github.com/tinybirdco/web-analytics-starter-kit/tree/main/tinybird \
--allow-destructive-operations
```

Das Kommando:

1. **Data Sources**: Events-Tabelle für Analytics
2. **Transformation Pipes**: Roh-Events zu aggregierten Metriken
3. **API-Endpoints**: SQL als REST
4. **Tokens**: Auth für Ingestion und Queries

Deployment dauert wenige Sekunden.

## Tracking-Skript ins Astro-Layout

Das Skript ist leicht (<9 KB gzipped), async und blockiert nicht.

Tracking-Skript in der Tinybird-Konsole per **Copy script** kopieren.

<img alt="Tinybird analytics setup in the Astro project dashboard" decoding="async" loading="eager" class="mt-4 border rounded-sm bg-cover bg-center bg-no-repeat transform will-change-auto" height="1736" width="3024" src="https://ik.imagekit.io/vjeqenuhn/launchfast-website/setup-tinybird-analytics-astro-1.png" />

In `src/layouts/Layout.astro` im `<head>`:

```astro {13-19}
---
// File: src/layouts/Layout.astro

// ...
---

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="generator" content={Astro.generator} />
    <!-- Tinybird Analytics -->
    <script
      defer
      data-host="https://api.tinybird.co"
      src="https://unpkg.com/@tinybirdco/flock.js"
      data-token="value-populates-while-copying-from-dashboard"
    ></script>
  </head>
  <body>
    <slot />
  </body>
</html>
```

`defer` lädt async ohne Render-Blockade.

## Analytics im gehosteten Dashboard

Tinybird liefert ein Dashboard, Dashboard-Token eingeben und Metriken sehen.

Dev-Server starten:

```bash
npm run dev
```

Site unter `http://localhost:4321` besuchen, Seiten wechseln, dann Analytics prüfen:

1. Dashboard öffnen (**View Dashboard** in der Konsole)
2. Echtzeit-Metriken:
   - steigende Page Views
   - Standort auf der Karte
   - Browser und Gerät

<img alt="Tinybird analytics events flowing into the Astro application" decoding="async" loading="eager" class="mt-4 border rounded-sm bg-cover bg-center bg-no-repeat transform will-change-auto" height="1846" width="3024" src="https://ik.imagekit.io/vjeqenuhn/launchfast-website/setup-tinybird-analytics-astro-2.png" />

Events erscheinen innerhalb von Sekunden. Ein Pageview reicht, Sie sind startklar.

## Fazit

Privacy-first Echtzeit-Analytics in Astro mit Tinybird: Page Views ohne Cookies, flexible Custom Events, leichtes Skript. Für Advanced Cases: [Tinybird Docs](https://www.tinybird.co/docs).

Fragen? [Twitter](https://twitter.com/direct_messages/create/rishi_raj_jain_).
