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/README.md
1# Cloudflare Web Analytics23Privacy-first web analytics providing Core Web Vitals, traffic metrics, and user insights without compromising visitor privacy.45## Overview67Cloudflare Web Analytics provides:8- **Core Web Vitals** - LCP, FID, CLS, INP, TTFB monitoring9- **Page views & visits** - Traffic patterns without cookies10- **Referrers & paths** - Traffic sources and popular pages11- **Device & browser data** - User agent breakdown12- **Geographic data** - Country-level visitor distribution13- **Privacy-first** - No cookies, fingerprinting, or PII collection14- **Free** - No cost, unlimited pageviews1516**Important:** Web Analytics is **dashboard-only**. No API exists for programmatic data access.1718## Quick Start Decision Tree1920```21Is your site proxied through Cloudflare?22├─ YES → Use automatic injection (configuration.md)23│ ├─ Enable auto-injection in dashboard24│ └─ No code changes needed (unless Cache-Control: no-transform)25│26└─ NO → Use manual beacon integration (integration.md)27├─ Add JS snippet to HTML28├─ Use spa: true for React/Vue/Next.js29└─ Configure CSP if needed30```3132## Reading Order33341. **[configuration.md](configuration.md)** - Setup for proxied vs non-proxied sites352. **[integration.md](integration.md)** - Framework-specific beacon integration (React, Next.js, Vue, Nuxt, etc.)363. **[patterns.md](patterns.md)** - Common use cases (performance monitoring, GDPR consent, multi-site tracking)374. **[gotchas.md](gotchas.md)** - Troubleshooting (SPA tracking, CSP issues, hash routing limitations)3839## When to Use Each File4041- **Setting up for first time?** → Start with configuration.md42- **Using React/Next.js/Vue/Nuxt?** → Go to integration.md for framework code43- **Need GDPR consent loading?** → See patterns.md44- **Beacon not loading or no data?** → Check gotchas.md45- **SPA not tracking navigation?** → See integration.md for `spa: true` config4647## Key Concepts4849### Proxied vs Non-Proxied Sites5051| Type | Description | Beacon Injection | Limit |52|------|-------------|------------------|-------|53| **Proxied** | DNS through Cloudflare (orange cloud) | Automatic or manual | Unlimited |54| **Non-proxied** | External hosting, manual beacon | Manual only | 10 sites max |5556### SPA Mode5758**Critical for modern frameworks:**59```json60{"token": "YOUR_TOKEN", "spa": true}61```6263Without `spa: true`, client-side navigation (React Router, Vue Router, Next.js routing) will NOT be tracked. Only initial page loads will register.6465### CSP Requirements6667If using Content Security Policy, allow both domains:68```69script-src https://static.cloudflareinsights.com https://cloudflareinsights.com;70```7172## Features7374### Core Web Vitals Debugging75- **LCP (Largest Contentful Paint)** - Identifies slow-loading hero images/elements76- **FID (First Input Delay)** - Interaction responsiveness (legacy metric)77- **INP (Interaction to Next Paint)** - Modern interaction responsiveness metric78- **CLS (Cumulative Layout Shift)** - Visual stability issues79- **TTFB (Time to First Byte)** - Server response performance8081Dashboard shows top 5 problematic elements with CSS selectors for debugging.8283### Traffic Filters84- **Bot filtering** - Exclude automated traffic from metrics85- **Date ranges** - Custom time period analysis86- **Geographic** - Country-level filtering87- **Device type** - Desktop, mobile, tablet breakdown88- **Browser/OS** - User agent filtering8990### Rules (Advanced - Plan-dependent)9192Create custom tracking rules for advanced configurations:9394**Sample Rate Rules:**95- Reduce data collection percentage for high-traffic sites96- Example: Track only 50% of visitors to reduce volume9798**Path-Based Rules:**99- Different behavior per route100- Example: Exclude `/admin/*` or `/internal/*` from tracking101102**Host-Based Rules:**103- Multi-domain configurations104- Example: Separate tracking for staging vs production subdomains105106**Availability:** Rules feature depends on your Cloudflare plan. Check dashboard under Web Analytics → Rules to see if available. Free plans may have limited or no access.107108## Plan Limits109110| Feature | Free | Notes |111|---------|------|-------|112| Proxied sites | Unlimited | DNS through Cloudflare |113| Non-proxied sites | 10 | External hosting |114| Pageviews | Unlimited | No volume limits |115| Data retention | 6 months | Rolling window |116| Rules | Plan-dependent | Check dashboard |117118## Privacy & Compliance119120- **No cookies** - Zero client-side storage121- **No fingerprinting** - No tracking across sites122- **No PII** - IP addresses not stored123- **GDPR-friendly** - Minimal data collection124- **CCPA-compliant** - No personal data sale125126**EU opt-out:** Dashboard option to exclude EU visitor data entirely.127128## Limitations129130- **Dashboard-only** - No API for programmatic access131- **No real-time** - 5-10 minute data delay132- **No custom events** - Automatic pageview/navigation tracking only133- **History API only** - Hash-based routing (`#/path`) not supported134- **No session replay** - Metrics only, no user recordings135- **No form tracking** - Page navigation tracking only136137## See Also138139- [Cloudflare Web Analytics Docs](https://developers.cloudflare.com/analytics/web-analytics/)140- [Core Web Vitals Guide](https://web.dev/vitals/)141- [GraphQL Analytics API Reference](../graphql-api/) - Query server-side analytics (HTTP, Workers, DNS, Firewall, etc.) via GraphQL142