All skills
Skillintermediate

Framework Integration

**Web Analytics is dashboard-only** - no programmatic API. This covers beacon integration.

Claude Code Knowledge Pack7/10/2026

Overview

Framework Integration

Web Analytics is dashboard-only - no programmatic API. This covers beacon integration.

Basic HTML

<script defer src='https://static.cloudflareinsights.com/beacon.min.js' 
        data-cf-beacon='{"token": "YOUR_TOKEN", "spa": true}'></script>

Place before closing </body> tag.

Framework Examples

FrameworkLocationNotes
React/Vitepublic/index.htmlAdd spa: true
Next.js App Routerapp/layout.tsxUse ``
Next.js Pagespages/_document.tsxUse ``
Nuxt 3app.vue with useHead()Or use plugin
Vue 3/Viteindex.htmlAdd spa: true
Gatsbygatsby-browser.jsonClientEntry hook
SvelteKitsrc/app.htmlBefore </body>
AstroLayout componentBefore </body>
Angularsrc/index.htmlAdd spa: true
Docusaurusdocusaurus.config.jsIn scripts array

Configuration

{
  "token": "YOUR_TOKEN",
  "spa": true
}

Use spa: true for: React Router, Vue Router, Next.js, Nuxt, Gatsby, SvelteKit, Angular

Use spa: false for: Traditional server-rendered (PHP, Django, Rails, WordPress)

CSP Headers

script-src 'self' https://static.cloudflareinsights.com;
connect-src 'self' https://cloudflareinsights.com;

GDPR Consent

// Load conditionally based on consent
if (localStorage.getItem('analytics-consent') === 'true') {
  const script = document.createElement('script');
  script.src = 'https://static.cloudflareinsights.com/beacon.min.js';
  script.defer = true;
  script.setAttribute('data-cf-beacon', '{"token": "YOUR_TOKEN", "spa": true}');
  document.body.appendChild(script);
}