# Analytics Forwarding (/reference/integrations/analytics)



The browser SDK captures all events and acts as an intelligent proxy — forwarding to your existing tools while building your own data lake.

How It Works [#how-it-works]

```
Browser → headless.ly/events → ┬→ Google Analytics (web analytics)
                                ├→ Sentry (error tracking)
                                ├→ PostHog (product analytics)
                                └→ Iceberg R2 Lakehouse (your data)
```

Setup [#setup]

```html
<script src="https://js.headless.ly/v1"
  data-tenant="my-startup"
  data-ga="G-XXXXXXXXXX"
  data-sentry-dsn="https://xxx@sentry.io/xxx"
  data-posthog-key="phc_xxx"
/>
```

One script tag. Events flow everywhere.

Or with npm:

```typescript
import { Headlessly } from '@headlessly/js'

Headlessly.init({
  ga: 'G-XXXXXXXXXX',
  sentryDsn: 'https://xxx@sentry.io/xxx',
  posthogKey: 'phc_xxx',
})
```

What Gets Captured [#what-gets-captured]

| Event Type            | Forwarded To     | Stored    |
| --------------------- | ---------------- | --------- |
| Pageviews, sessions   | Google Analytics | Lakehouse |
| JavaScript errors     | Sentry           | Lakehouse |
| Feature usage, clicks | PostHog          | Lakehouse |
| Custom events         | All configured   | Lakehouse |

Progressive Capability [#progressive-capability]

* **Phase 1**: Forward everything, store everything
* **Phase 2**: Basic funnel analysis from your own data
* **Phase 3**: Replace external tools one by one

Day 1: external tools handle the heavy lifting. Over time, the lakehouse enables more. You never lose data.

Edge Proxy [#edge-proxy]

Cloudflare Snippets handle the proxy at the edge:

* Intercept analytics/error requests
* Forward to external providers
* Also forward to ingest endpoint
* Zero latency impact (\< 5ms, \< 32KB)
