What is Cloudflare Analytics?
- No cookies required
- Privacy-friendly measurement
- May be automatically enabled if you are using Cloudflare Pages
Setup Steps
- Go to the Cloudflare dashboard → “Analytics & Logs” → “Web Analytics”
- Click “Add a site” → enter your URL
- Copy the generated script tag
Paste it just before the </body> closing tag in your Astro layout file.
<script defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "YOUR_TOKEN"}'></script>
Data Available
- Page views and unique visitors
- Top pages and referrers
- Traffic by country
Gotchas
- Data may take a few hours to appear
- Because no cookies are used, the script is less likely to be blocked by ad blockers
While setting up Analytics, also configure SEO meta tags in Astro to complete your site’s measurement foundation.
Related Articles
- How to Deploy Astro to Cloudflare Pages
- How to Add a New Page in Astro
- Google Search Console HTML File Verification with Astro and Cloudflare Pages
- Cloudflare Pages GitHub Auto-Deploy Not Working: How to Fix It
Recommended Services
- Fiverr - Find freelance developers and tech experts