Skip to main content

How to add GoatCounter Analytics to your Hugo website

As an alternative to Google Analytics, you can use the open source GoatCounter hosted analytics solution. Setting it up is fast and easy. You can find instructions on their website, but here are some tips specific to Hugo.

Create an account on GoatCounter #

Create an account on the sign-up page. It’s free for non-commercial use.

Configure Hugo #

  1. If you set the googleAnalytics parameter in your config.toml file, comment it out or remove it.

  2. Override your theme’s analytics partial by creating a layouts/partials/analytics.html file.

    <script data-goatcounter="https://YOURSITENAME.goatcounter.com/count"
            async src="//gc.zgo.at/count.js"></script>
    
  3. Rebuild and republish your site. This step requires no mental energy if you deploy on Netlify.

The Dashboard #

Analytics collection begins immediately.

GoatCounter Dashboard

References #