← All guides

Website analytics

Count page views and see which pages are read most. The optional program in your download runs on your own Cloudflare account, with your own database. Your website can stay on Cloudflare Pages, Netlify or your usual hosting.

  • optional
  • your own Cloudflare account
  • no cookies or browser storage
  • Node.js and terminal required

Search Console and website analytics

Get found on Google shows what happens in Google Search: search terms, impressions and clicks. Website analytics counts page loads on your website, including traffic from other sources.

This Worker counts page views, not unique visitors. Reloading a page can add another view. It does not identify people or report countries, devices, time on site or clicks on your phone number. Blocked requests and bots can make the totals incomplete.

What the overview shows

SectionWhat you see
Daily viewsPage views for each of the last 30 days, using UTC dates, and a total for that period.
Most read pagesUp to 20 page paths, ranked by page views over those 30 days.
Referring domainsUp to 20 referring hostnames over those 30 days. An empty source appears as “direct / unknown”.

Before you start

  • Put your website online on your own HTTPS address; see Get your site online.
  • In configurator.html, open Search engines (SEO) and fill in Your website address (including https://). Download and unzip the package.
  • Find analytics-worker next to web. It contains analytics.js, schema.sql and wrangler.jsonc, even when analytics is off.
  • Have your own Cloudflare account on Workers Free and install a supported version of Node.js from nodejs.org. Cloudflare’s CLI setup guide lists its current requirements.
A separate program

Only the web folder goes to your website hosting. Set up analytics-worker separately using the steps below. Your domain’s nameservers and website host do not need to change.

Open the Worker folder and sign in

Open a terminal in the unpacked analytics-worker folder. On macOS, select that folder in Finder and use Services → New Terminal at Folder if available. On Windows, open it in File Explorer and use Open in Terminal. Run every command below from this folder.

npx wrangler login

Follow the sign-in prompt for your own Cloudflare account. The first command may ask to install Wrangler; accept that prompt.

Open this folder’s wrangler.jsonc in a plain text editor:

  • name: choose a unique Worker name on your account, for example my-business-analytics. Keep main pointing to analytics.js.
  • SITE_ORIGIN: your website’s exact origin, for example https://www.yourdomain.com, with no path or trailing slash. The configurator fills it from your website address; check it. If pages are served on several origins, separate them with commas.
  • namespace_id inside ratelimits: use an integer unique among the rate-limit bindings on your account. The supplied value is 1007; choose another if already used. Keep the binding names DB and HIT_LIMITER.

Create your database

npx wrangler d1 create website-analytics -c wrangler.jsonc

Copy the returned database_id into the d1_databases entry in this wrangler.jsonc, replacing PASTE-YOUR-D1-DATABASE-ID-HERE. Make sure database_name matches the database you created. If Wrangler offers to update your configuration, check that it updates the existing DB entry.

If you already use that database name for another website, choose a different name, update database_name and use the same name in both database commands. Give each website its own database.

Create the table in the remote database:

npx wrangler d1 execute website-analytics --remote --file schema.sql -c wrangler.jsonc

The --remote flag matters: without it you would prepare a local database rather than the one your deployed Worker uses. The supplied schema stores daily totals per page path and referring hostname.

Deploy and protect the overview

npx wrangler deploy -c wrangler.jsonc

Save the HTTPS address printed by Wrangler, for example https://my-business-analytics.your-account.workers.dev.

Use the Worker’s own configuration

Run from analytics-worker with -c wrangler.jsonc. Its configuration has no website assets. The deployment output should not mention uploading website assets; if it does, stop and check your folder and configuration.

Set the password for your private overview:

npx wrangler secret put STATS_TOKEN -c wrangler.jsonc

At the prompt, enter a long random password: at least 16 ASCII characters, preferably 32 or more. Save it in your password manager. Do not put it in the configurator, website files or an address. The program requires this secret before it will show statistics.

Connect the website

  1. Open configurator.html and load your my-website.json.
  2. In Search engines (SEO), find Your analytics Worker address.
  3. Paste only the Worker’s HTTPS address, with no /hit, /stats, query or password.
  4. Download the website again and upload the new web folder to your hosting. Keep the new my-website.json for future changes.

The configurator adds a small page-view request to each generated HTML page and updates the security policy it generates for your form. It does not load an external analytics script. If you set a separate security policy at your hosting, its connect-src must also allow your Worker’s origin.

Leave Your analytics Worker address empty to turn measurement off; download and upload the website again. A blank field adds no measurement request. Files opened directly on your computer are not counted.

Read and check your statistics

Visit a page of your published website. Then open your Worker address with /stats at the end:

https://my-business-analytics.your-account.workers.dev/stats

Your browser asks for a username and password. Enter username stats and the password you set as STATS_TOKEN. Refresh the overview to see new totals. Opening the Worker’s base address alone returns “Not found”; the overview is at /stats.

If no views appear, check the published website address against SITE_ORIGIN (including www), the address in the configurator, and that the new web files were uploaded. Also check the D1 database ID, remote table, DB and HIT_LIMITER bindings, hosting security policy and Cloudflare quotas. A blocker may prevent a test visit from being counted.

If login keeps failing, check the username and password; a missing secret or a password shorter than 16 characters is rejected. To replace the password, run the same secret put STATS_TOKEN command again.

Free limits and what happens when they run out

Limits checked on 10 October 2026: Workers Free allows 100,000 requests per account per day, resetting at midnight UTC. This includes other Workers on the account and requests to this overview, not just page views.

D1 Free includes 100,000 rows written and 5 million rows read per day, with 5 GB total storage per account. Each Free database is limited to 500 MB. Index work can count as additional writes, so 100,000 writes is not a promise of 100,000 measured page views.

When a daily Free quota is used up, requests or database queries fail until the daily quota resets. A full database or storage quota does not reset each day. The program does not automatically delete old totals: the overview shows 30 days, but older totals remain stored.

Failed measurement does not block the static website or navigation. It can leave gaps in the totals or make /stats unavailable. Shared account quotas can also affect other Workers, including your contact form. On a paid plan, additional usage may be billed; keep Workers Free if you want the Free limits.

The supplied configuration also limits measurements to approximately 120 per minute per website origin at each Cloudflare location. Excess requests are not counted. This is a local limit, not a worldwide cap.

What is stored

The database holds daily counts, page paths and referring hostnames. The program does not store visitor IP addresses, user agents, individual visit times, identifiers, query parameters, URL fragments or full referring addresses, and it uses no cookies or browser storage. Cloudflare receives the network requests as your infrastructure provider; that is separate from what this program stores. The supplied configuration disables Worker request logging.

The configurator includes wording for the website’s privacy policy when analytics is enabled. Review that wording for your own website and jurisdiction.

Need help? Write to support@maxitemplates.com.

Based on the supplied analytics Worker and README.txt. Cloudflare documentation checked on 10 October 2026: D1 commands, Worker secrets and rate limiting. Deployment on your own account is a separate step.

Next guide: Take bookings