Skip to main content
  1. Posts/

Adding GoatCounter to Hugo

·263 words·2 mins
muffn_
Author
muffn_
🐶
Table of Contents

📔 Intro
#

I no longer use Goatcounter. I instead use Umami. This tutorial will still work if you wish you use Goattcounter though.

I just posted about how I migrated from WordPress to Hugo here:

How I Migrated From WordPress to Hugo
·2303 words·11 mins

and there I noted about wanting to remove Google Analytics in favor of something less …evil.

After seeing how simple it was to accomplish, I went ahead and did it. Here’s how:

🔧 Adding GoatCounter to Hugo
#

Sign Up For GoatCounter or Selfhost
#

I have signed up at the time of writing, but if I like it enough I will move this to a self-hosted solution. This will allow me to get around adblockers that are already blocking gc.zgo.at which is used by the GoatCounter hosted service.

If I should be getting around people blocking my analytics is another topic, but this one is pretty reasonable in my opinion.

Add GoatCounter
#

Get the javascript given to you by GoatCounter, it will look like this with your analytics code. Optionally just nab this and add your code in.

<script data-goatcounter="https://<YOUR-CODE-HERE>.goatcounter.com/count"
        async src="//gc.zgo.at/count.js"></script>

Place this in layouts/partials/analytics.html. You can overwrite your old one or .old it as I did.

Comment out googleAnalytics = in config.toml.

Commit & Build
#

Save all changes, commit your site, and let it rebuild, and you should now have data in GoatCounter, assuming you’re not adblocking it.

🏁 Fin
#

So far this seems like exactly what I wanted. Views on my pages, basic stats and referrer. Cool.

~~Muffn