Back to templates

Template details

Busuanzi

Self-hosted busuanzi visitor statistics system built with Golang and Redis.

About this template

Busuanzi is a self-hosted website visit statistics tool written in Golang and backed by Redis that counts unique visitors (UV) and page views (PV) for both the whole site and individual subpages.

What is Busuanzi?

Busuanzi is a simple visitor statistics system built on Golang and Redis. It accepts requests from your website's script tag, logs each visit into Redis, and exposes the counts via a lightweight API. The project is maintained by soxft and is published on GitHub; it can be compiled from source or run with Docker.

Key Features

  • UV and PV counting — Tracks unique visitors (UV) via Redis HyperLogLog and page views (PV) via simple counters, separately for the entire site and for each subpage.
  • Privacy protection — Stores only a HASH of the visitor identifier, never the raw IP or user agent.
  • Docker one-click deployment — Ships a docker-compose.yaml; run docker-compose up -d and visit http://localhost:8080 to see the data.
  • Pjax compatibility — Works on Pjax-based themes because the counting script handles partial page loads without a full refresh.
  • Data migration from the original busuanzi — A companion tool busuanzi-sync imports historical counts from the hosted busuanzi service (busuanzi.ibruce.info).
  • Upgrade path for 2.5.x – 2.7.x — The bsz-transfer utility migrates data to the 2.8.x version.
  • Redis persistence — Uses Redis RDB and AOF mechanisms to keep visit data durable across restarts.
  • Tencent EdgeOne integration — The demo instance is CDN-accelerated and protected by Tencent EdgeOne, which offers a free plan.

Who is it for?

  • Blog owners using Hexo or Hugo — Add a snippet to your theme to display busy counts without relying on the public busuanzi service.
  • Site administrators who want data ownership — Self-host the counter to keep visit data on your own server instead of a third party.
  • Developers needing a lightweight analytics API — Use the JSON responses from the Go backend for custom dashboards.

What can you do with Busuanzi?

  • Personal blogs: Show “site visits” and “page views” in the footer or sidebar with just a few lines of JavaScript.
  • Small websites: Get per-page trends through the stored ZSet of page PV, which can be queried later.
  • Pjax-based single-page sites: Keep the counter working when content is swapped without full reloads.

How does Busuanzi work?

When a visitor loads a page, the embedded script sends a request to the self-hosted server. The server reads the visitor's identifier, stores it in Redis as a HyperLogLog for UV counting, and increments the page PV ZSet for the requested path. The data is stored under keys like bsz:site_pv:md5(host), bsz:site_uv:md5(host), and bsz:page_pv:md5(host)/md5(path).

Alternatives

  • Original busuanzi — The hosted service at busuanzi.ibruce.info that this project can sync from; it requires no self-hosting but gives you less control over your data.

FAQ

Is Busuanzi free?

Yes, the source code is available on GitHub and can be self-hosted without paying license fees or usage charges. The project also mentions CDN sponsorship from Tencent EdgeOne, but using the software itself is free.

What does Busuanzi do?

It counts unique visitors (UV) and page views (PV) for your whole site and for each subpage. The counts are stored in Redis and can be displayed anywhere on your website by embedding a small script.

Can I migrate from the original busuanzi?

Yes, use the busuanzi-sync utility to import historical statistics from the original busuanzi service, or use bsz-transfer to move data between versions 2.5.x-2.7.x and 2.8.x.

Does Busuanzi support Pjax?

Yes, Busuanzi is compatible with Pjax-enabled pages, meaning it will continue counting visits when content is asynchronously loaded without a full page reload.

What are the hardware requirements?

The project only requires a Go runtime or Docker and a Redis instance, so it runs on any VPS or server that supports these. Exact resource numbers are not specified.

screenshot of Busuanzi on template0.com