diff --git a/docs/content/docs/guide/configuration.md b/docs/content/docs/guide/configuration.md index 5cfd0e5..776fdc1 100644 --- a/docs/content/docs/guide/configuration.md +++ b/docs/content/docs/guide/configuration.md @@ -383,16 +383,6 @@ excludeSearch: true --- ``` -### Google Analytics - -To enable [Google Analytics](https://marketingplatform.google.com/about/analytics/), set `services.googleAnalytics.ID` flag in `hugo.yaml`: - -```yaml {filename="hugo.yaml"} -services: - googleAnalytics: - ID: G-MEASUREMENT_ID -``` - ### Google Search Index To [block Google Search](https://developers.google.com/search/docs/crawling-indexing/block-indexing) from indexing a page, set `noindex` to true in your page frontmatter: @@ -409,7 +399,25 @@ To exclude an entire directory, use the [`cascade`](https://gohugo.io/configurat > To block search crawlers, you can make a [`robots.txt` template](https://gohugo.io/templates/robots/). > However, `robots.txt` instructions do not necessarily keep a page out of Google search results. -### Umami Analytics +### Analytics + +Hextra has support for several different analytics solutions. Hextra only supports analytics in production environments. This is to ensure that you do not accidentally send analytic events when working locally. If, however, you do want to test analytics locally, you can run a production server using: + +``` +hugo server --environment production +``` + +#### Google Analytics + +To enable [Google Analytics](https://marketingplatform.google.com/about/analytics/), set `services.googleAnalytics.ID` flag in `hugo.yaml`: + +```yaml {filename="hugo.yaml"} +services: + googleAnalytics: + ID: G-MEASUREMENT_ID +``` + +#### Umami Analytics To enable [Umami](https://umami.is/docs/), set `params.analytics.umami.serverURL` and `params.analytics.umami.websiteID` flag in `hugo.yaml`: @@ -436,7 +444,7 @@ params: # doNotTrack: "true" # optional ``` -### Matomo Analytics +#### Matomo Analytics To enable [Matomo](https://matomo.org/), set `params.analytics.matomo.URL` and `params.analytics.matomo.ID` flag in `hugo.yaml`: @@ -448,6 +456,32 @@ params: websiteID: "94db1cb1-74f4-4a40-ad6c-962362670409" ``` +#### GoatCounter Analytics + +To enable [GoatCounter](https://www.goatcounter.com/), set `params.analytics.goatCounter.code` in `hugo.yaml` +All settings available here are mirrors of the settings described in GoatCounter [settings](https://www.goatcounter.com/help/js#settings-44186) + +```yaml {filename="hugo.yaml"} +params: + analytics: + goatCounter: + code: "ABCDE" + + # Optional Settings + #------------------ + # disables automatic collection of data + # noOnload: true + + # disables event binding. See more here https://www.goatcounter.com/help/events + # noEvents: true + + # allows data collection from local addresses. Use this with a production environment to test locally + # allowLocal: true + + # Allow data collection when a page is loaded in a frame or iframe + # allowFrame: true +``` + ### LLMS.txt Support To enable [llms.txt](https://llmstxt.org/) output format for your site, which provides a structured text outline for [large language models](https://en.wikipedia.org/wiki/Large_language_model) and AI agents, add the `llms` output format to your site's `hugo.yaml`: diff --git a/layouts/_partials/components/analytics/analytics.html b/layouts/_partials/components/analytics/analytics.html index adbb981..6e56b52 100644 --- a/layouts/_partials/components/analytics/analytics.html +++ b/layouts/_partials/components/analytics/analytics.html @@ -16,4 +16,9 @@ {{ partial "components/analytics/matomo.html" . }} {{- end }} + +{{- if .Site.Params.analytics.goatCounter -}} + {{ partial "components/analytics/goat-counter.html" . }} +{{- end -}} + {{- end }} diff --git a/layouts/_partials/components/analytics/goat-counter.html b/layouts/_partials/components/analytics/goat-counter.html new file mode 100644 index 0000000..3399bb0 --- /dev/null +++ b/layouts/_partials/components/analytics/goat-counter.html @@ -0,0 +1,17 @@ +{{- with .Site.Params.analytics.goatCounter -}} + {{- if not .code -}} + {{- errorf "Missing GoatCounter 'code' configuration. See https://imfing.github.io/hextra/versions/latest/docs/guide/configuration/#goatcounter-analytics" -}} + {{- end -}} + + +{{- end -}} \ No newline at end of file