Analytics for GitHub Pages Without Domain | Generated by AI
Question: What if I didn’t add a domain, I just use Web Analytics / logs for my blog that is hosted on GitHub Pages with the GitHub domain?
Answer:
You can use Cloudflare Web Analytics for a blog hosted on GitHub Pages (using either the default username.github.io or a project subdomain like username.github.io/repo) without adding any domain to Cloudflare and without changing your DNS or nameservers.
Cloudflare Web Analytics is specifically designed for this exact scenario: it is a privacy-first, lightweight JavaScript-based tracker that works completely independently of Cloudflare’s proxy, DNS, or domain setup. It does not require a Zone ID (because no zone/domain is added to your account), and it collects data client-side via a small beacon script.
How to set it up for your GitHub Pages blog
- Log in to your Cloudflare dashboard (free account is fine).
- Go to Analytics & Logs → Web Analytics (or directly search for “Web Analytics” in the dashboard).
- Click Add a site (or “Create” / “Add site”).
- Enter your GitHub Pages hostname exactly as visitors see it:
- For user/organization site:
username.github.io - For project site:
username.github.io/repo-name
- For user/organization site:
- Cloudflare will generate a small JavaScript snippet (usually ~1 KB) that looks something like this:
<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "YOUR_UNIQUE_TOKEN_HERE"}'></script> - Add this snippet to the
<head>section of your site’s HTML files (or in your Jekyll/Hugo/etc. layout template if using a static site generator).- For plain HTML: edit
index.htmland other pages. - For Jekyll: add it to
_includes/head.htmlor equivalent. - Push the change → GitHub Pages will rebuild and deploy automatically.
- For plain HTML: edit
- After a few hours/days of traffic, view your stats in the same Web Analytics section of the dashboard.
Key points and limitations
- No Zone ID needed — You never see or use a Zone ID here because you’re not adding a zone/domain.
- No proxy / performance features — You won’t get Cloudflare’s caching, DDoS protection, image optimization, etc. (those require proxying traffic, which means using Cloudflare DNS + adding the domain).
- Data is privacy-friendly — No cookies, no personal IPs stored, GDPR-friendly.
- Works on any hostname — Including
*.github.io, custom domains not pointed to Cloudflare, localhost during dev, etc. - Alternative for Pages projects — If you ever migrate your blog from GitHub Pages to Cloudflare Pages (highly recommended for better speed, free analytics integration, and custom domains), you can enable Web Analytics with one click in the project settings (Metrics → Enable), and Cloudflare auto-injects the snippet on deploy — no manual code edit needed.
This is the simplest and most common way people add free, decent analytics to pure GitHub Pages sites without touching DNS.
References:
- Enabling Cloudflare Web Analytics - Get started
- Enable Web Analytics for Pages projects
- FAQs - Cloudflare Web Analytics
- Cloudflare Web Analytics for sites not proxied through Cloudflare