skills-templates/cloudflare-web-analytics/SKILL.md
# Cloudflare Web Analytics > Privacy-first, free web analytics with Core Web Vitals, real user monitoring, and automatic SPA support. ## Quick Reference ### Key Features | Feature | Description | |---------|-------------| | **Privacy-First** | No cookies, no personal data, no fingerprinting | | **Free** | Available on all Cloudflare plans including free | | **Core Web Vitals** | LCP, CLS, INP, FCP metrics | | **SPA Support** | Automatic single-page application tracking | | **No DNS Required*
npx skillsauth add enuno/claude-command-and-control skills-templates/cloudflare-web-analyticsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Privacy-first, free web analytics with Core Web Vitals, real user monitoring, and automatic SPA support.
| Feature | Description | |---------|-------------| | Privacy-First | No cookies, no personal data, no fingerprinting | | Free | Available on all Cloudflare plans including free | | Core Web Vitals | LCP, CLS, INP, FCP metrics | | SPA Support | Automatic single-page application tracking | | No DNS Required | Works without Cloudflare proxy | | 6-Month Retention | Historical data access |
| Method | When to Use | |--------|------------| | Automatic | Sites proxied through Cloudflare | | Manual JS | Non-proxied sites, custom control | | Pages | Cloudflare Pages projects (one-click) |
For sites already using Cloudflare's proxy:
Note: Sites with Cache-Control: public, no-transform headers require manual setup.
Add before the closing </body> tag:
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_SITE_TOKEN"}'
></script>
Get your token:
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_TOKEN"}'
></script>
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| token | string | required | Your site token |
| spa | boolean | true | Enable SPA tracking |
Using data attribute:
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_TOKEN", "spa": false}'
></script>
Using query string (GTM):
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js?token=YOUR_TOKEN&spa=false"
></script>
Cloudflare Web Analytics automatically tracks SPA navigation by:
pushState methodonpopstate eventsRoute changes send data for the previous route to the beacon endpoint. The last route measurement is sent when the user leaves the tab using Navigator.sendBeacon.
| Framework | Support | |-----------|---------| | React | Full | | Vue.js | Full | | Angular | Full | | Next.js | Full | | Nuxt.js | Full | | Hash-based routers | Not supported |
example.com/#/page)| Metric | Description | |--------|-------------| | Visits | Page view from different website or direct link | | Page Views | Successful HTTP response with HTML content-type | | Page Load Time | Total time required to load the page | | Core Web Vitals | Google's user experience metrics |
| Metric | Description | Rating | |--------|-------------|--------| | LCP (Largest Contentful Paint) | Main content load time | Good/Needs Improvement/Poor | | INP (Interaction to Next Paint) | UI responsiveness to interactions | Good/Needs Improvement/Poor | | CLS (Cumulative Layout Shift) | Visual stability during load | Good/Needs Improvement/Poor |
Note: Core Web Vitals currently only work in Chromium browsers. Safari and Firefox support coming soon.
| Metric | Description | |--------|-------------| | FCP (First Contentful Paint) | Time to first content render | | TTFB (Time to First Byte) | Server response time | | First Paint | Time to any visual change |
| Dimension | Description | |-----------|-------------| | Country | Visitor's country | | Host | Domain of the site's URL | | Path | Internal links referring visits | | Referer | External links referring visits | | Device Type | Desktop, mobile, or tablet | | Browser | Chrome, Safari, Firefox, etc. | | Operating System | Windows, macOS, iOS, Android, etc. | | Site | Website's domain name |
Enable Exclude Bots filter to remove automated traffic for accurate user metrics.
Below visualizations, view detailed breakdowns by:
Rules control tracking for specific websites or paths:
Note: Rules are only available for sites proxied through Cloudflare.
Configuration rules take priority over Web Analytics rules. If a configuration rule disables tracking, it overrides any Web Analytics rule enabling it.
Cloudflare Web Analytics is designed with privacy in mind:
Exclude visitors from EU data centers:
Free plan customers have EU traffic automatically excluded.
Query strings are not logged to avoid collecting potentially sensitive data. UTM parameter support may be added in the future.
POST https://api.cloudflare.com/client/v4/graphql
API Token (Recommended):
curl -X POST https://api.cloudflare.com/client/v4/graphql \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "..."}'
API Key:
curl -X POST https://api.cloudflare.com/client/v4/graphql \
-H "X-Auth-Email: [email protected]" \
-H "X-Auth-Key: YOUR_GLOBAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "..."}'
{
viewer {
zones(filter: { zoneTag: $zoneTag }) {
# Dataset and fields
}
}
}
query {
viewer {
zones(filter: { zoneTag: "YOUR_ZONE_ID" }) {
httpRequestsAdaptiveGroups(
filter: {
datetime_gt: "2024-01-01T00:00:00Z"
datetime_lt: "2024-01-02T00:00:00Z"
}
limit: 10
orderBy: [datetime_DESC]
) {
dimensions {
datetime
deviceType
}
count
}
}
}
}
{
"query": "query($zoneTag: String!, $start: Time!, $end: Time!) { ... }",
"variables": {
"zoneTag": "YOUR_ZONE_ID",
"start": "2024-01-01T00:00:00Z",
"end": "2024-01-02T00:00:00Z"
}
}
| Filter | Description |
|--------|-------------|
| datetime_gt | Greater than timestamp |
| datetime_lt | Less than timestamp |
| date | Specific date |
| limit | Maximum results |
| orderBy | Sort order (e.g., datetime_DESC) |
| Issue | Cause | Solution | |-------|-------|----------| | CORS errors | Hostname mismatch | Verify hostname matches configured site | | No data appearing | Ad-blockers | Use automatic injection for proxied sites | | Missing final route | SPA data loss | Expected behavior in older browsers | | Automatic setup fails | Cache headers | Use manual JS snippet instead |
The JavaScript beacon may be blocked by:
Solution: For proxied sites, use automatic injection (edge analytics cannot be blocked).
Cloudflare uses postfix matching for hostname validation. Ensure your domain exactly matches the configured analytics site.
Automatic injection doesn't work with:
Cache-Control: public, no-transform
Solution: Use manual JavaScript snippet installation.
| Limitation | Details | |------------|---------| | Account limit | Soft limit of 10 sites per account (contact support to increase) | | Single snippet | Only one JS snippet per page | | Custom events | Not currently supported | | UTM parameters | Not yet supported | | Hash routing | Not supported for SPAs | | Browser support | Core Web Vitals require Chromium |
For proxied sites, automatic injection provides:
<body>
<!-- Your content -->
<!-- Place beacon just before closing body tag -->
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_TOKEN"}'
></script>
</body>
Before deployment, confirm your SPA uses History API routing (not hash-based).
Regularly check CWV scores and address:
Enable bot exclusion for accurate user metrics in production environments.
// public/index.html
<!DOCTYPE html>
<html>
<head>
<title>My React App</title>
</head>
<body>
<div id="root"></div>
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_TOKEN"}'
></script>
</body>
</html>
// pages/_document.js
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_TOKEN"}'
/>
</body>
</Html>
)
}
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<title>My Vue App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "YOUR_TOKEN"}'
></script>
</body>
</html>
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js?token=YOUR_TOKEN"
></script>
For SPA with GTM, disable SPA tracking if managing navigation events manually:
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js?token=YOUR_TOKEN&spa=false"
></script>
tools
MemPalace local-first AI memory system. Use when setting up persistent memory for Claude Code sessions, mining project files or conversation transcripts, querying past context, configuring MCP tools, managing the knowledge graph, or troubleshooting palace operations.
tools
LangSmith Python SDK — trace, evaluate, and monitor LLM applications. Covers @traceable decorator, trace context manager, Client API, evaluate() / aevaluate(), comparative evaluation, custom evaluators, dataset management, prompt caching, ASGI middleware, and pytest plugin.
development
LangGraph (Python) — build stateful, controllable agent graphs with checkpointing, streaming, persistence, interrupts, fault tolerance, and durable execution. Covers both Graph API (StateGraph) and Functional API (@entrypoint/@task).
development
LangGraph Graph API (Python) — build explicit DAG agent workflows with StateGraph, typed state, nodes, edges, Command routing, Send fan-out, checkpointers, interrupts, and streaming. Use when you need explicit control flow and graph topology.