Setting Up Page Analytics for My Blog

Writing a blog without knowing if anyone’s reading feels empty. Analytics isn’t for KPIs, just for fun.

This blog has two analytics systems, each with its own purpose.

Busuanzi shows on article pages, readers can see how many times each article has been viewed. Open source, no registration needed, just include a script.

Google Analytics runs in the background, only I can see it. Used for traffic sources, user distribution, popular content, etc.

They don’t interfere with each other.

Busuanzi (Frontend Display)

Busuanzi is a minimal page view counter. No dashboard, no backend — just a counter and a JS script.

Loading the Script

In layouts/partials/js.html:

{{ if .IsPage }}
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{{ end }}

Only loads on article pages, not on homepage or listing pages.

Displaying Page Views

In article template layouts/_default/single.html:

<div class="article-tag">
  <i class="fa fa-eye"></i>
  <span id="busuanzi_container_page_pv">
    <span id="busuanzi_value_page_pv">0</span>
  </span>
</div>

Busuanzi’s script auto-finds id="busuanzi_value_page_pv" and fills in the view count. Data stored on Busuanzi’s server.

How It Works

  1. Page loads, Busuanzi script sends request to busuanzi.ibruce.info
  2. Server counts the visit for the current URL path
  3. Returns the view count for that page
  4. Script updates the DOM element

Each page visit increments the counter by 1. Data is global per URL path, regardless of domain.

Accuracy is not great — sometimes refreshing doesn’t immediately show +1. But as a rough number shown to readers, it’s good enough.

Google Analytics (Backend Analysis)

Busuanzi only gives view counts. For questions like “where are visitors from”, “what devices do they use”, “which articles are popular”, you need Google Analytics.

Loading the Script

Also in layouts/partials/js.html:

{{ if not (in (hostname) "localhost") }}
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-129382678-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-129382678-1', {
    'anonymize_ip': true
  });
</script>
{{ end }}

Only loads in production. Local development doesn’t trigger it, avoiding polluted stats.

anonymize_ip enables IP anonymization, GDPR compliant.

What’s Tracked

  • Traffic sources: Google search, direct, social media, referrals
  • Devices: desktop/mobile, OS, browser
  • Geography: country/city
  • Behavior: pages visited, time on site, bounce rate

Most useful data: traffic sources and popular content. Knowing which articles get searched and where traffic comes from helps decide what to write next.

Privacy

GA involves user tracking. Some mitigations:

  • IP anonymization enabled
  • No advertising features (no remarketing, no audience analysis)
  • No personal identity tracking

For a tech blog, there’s no need to over-track readers. A rough traffic trend is enough.

That said, GA gets blocked by ad blockers. Many tech blog readers run adblock. So GA data is also incomplete. Look at trends, don’t obsess over exact numbers.

Comparison

BusuanziGoogle Analytics
VisibilityPublic, reader-facingPrivate, owner only
DataSingle page viewsTraffic, sources, devices, behavior
SetupOne script + one spanOne gtag snippet
AccuracyAverageHigh
Privacy impactLowMedium
Account neededNoGoogle account
ServerBusuanzi maintainedGoogle maintained

Performance

Busuanzi script ~5KB, async load, non-blocking. GA gtag script also async.

Both only load on article pages, homepage and listing pages unaffected. Impact on overall page load speed is negligible.

One thing: Busuanzi’s server is in China, overseas access can be slow. But page view count is just a display number, slow load doesn’t affect functionality. It’s loaded with async, failure doesn’t break anything.

Article Link:

/en/archive/blog-architecture-analytics/

# Related Articles