Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/web-analytics/configuration.md
1# Configuration23## Setup Methods45### Proxied Sites (Automatic)67Dashboard → Web Analytics → Add site → Select hostname → Done89| Injection Option | Description |10|------------------|-------------|11| Enable | Auto-inject for all visitors (default) |12| Enable, excluding EU | No injection for EU (GDPR) |13| Enable with manual snippet | You add beacon manually |14| Disable | Pause tracking |1516**Fails if response has:** `Cache-Control: public, no-transform`1718**CSP required:**19```20script-src https://static.cloudflareinsights.com https://cloudflareinsights.com;21```2223### Non-Proxied Sites (Manual)2425Dashboard → Web Analytics → Add site → Enter hostname → Copy snippet2627```html28<script defer src='https://static.cloudflareinsights.com/beacon.min.js'29data-cf-beacon='{"token": "YOUR_TOKEN", "spa": true}'></script>30```3132**Limits:** 10 non-proxied sites per account3334## SPA Mode3536**Enable `spa: true` for:** React Router, Next.js, Vue Router, Nuxt, SvelteKit, Angular3738**Keep `spa: false` for:** Traditional multi-page apps, static sites, WordPress3940**Hash routing (`#/path`) NOT supported** - use History API routing.4142## Token Management4344- Found in: Dashboard → Web Analytics → Manage site45- **Not secrets** - domain-locked, safe to expose in HTML46- Each site gets unique token4748## Environment Config4950```typescript51// Only load in production52if (process.env.NODE_ENV === 'production') {53// Load beacon54}55```5657Or use environment-specific tokens via env vars.5859## Verify Installation60611. DevTools Network → filter `cloudflareinsights` → see `beacon.min.js` + data request622. No CSP/CORS errors in console633. Dashboard shows pageviews after 5-10 min delay6465## Rules (Plan-dependent)6667Configure in dashboard for:68- **Sample rate** - reduce collection % for high-traffic69- **Path-based** - different behavior per route70- **Host-based** - separate tracking per domain7172## Data Retention7374- 6 months rolling window75- 1-hour bucket granularity76- No raw export, dashboard only77