mirror of https://github.com/luizdepra/hugo-coder.git

Nour Agha
09.22.2023 d336b3cc3a65adafb5bcc436806fe22ce4117e94
Add Pirsch analytics (#795)

### Prerequisites

Put an `x` into the box(es) that apply:

- [ ] This pull request fixes a bug.
- [x] This pull request adds a feature.
- [ ] This pull request introduces breaking change.

### Description

Adds support for [Pirsch](https://pirsch.io) analytics.

One of the best privacy-friendly, open source and lightweight analytics
providers.

### Issues Resolved

N/A

### Checklist

Put an `x` into the box(es) that apply:

#### General

- [x] Describe what changes are being made
- [x] Explain why and how the changes were necessary and implemented
respectively
- [ ] Reference issue with `#<ISSUE_NO>` if applicable

#### Resources

- [ ] If you have changed any SCSS code, run `make release` to
regenerate all CSS files

#### Contributors

- [ ] Add yourself to `CONTRIBUTORS.md` if you aren't on it already

Signed-off-by: Nour Agha <nour@agha.dev>
Co-authored-by: Luiz F. A. de PrĂ¡ <luizdepra@users.noreply.github.com>
3 files modified
2 files added
18 ■■■■■ changed files
docs/analytics.md 1 ●●●● patch | view | raw | blame | history
docs/analytics/pirsch.md 6 ●●●●● patch | view | raw | blame | history
exampleSite/config.toml 4 ●●●● patch | view | raw | blame | history
layouts/_default/baseof.html 4 ●●●● patch | view | raw | blame | history
layouts/partials/analytics/pirsch.html 3 ●●●●● patch | view | raw | blame | history
docs/analytics.md
@@ -12,6 +12,7 @@
* [Goat Counter](https://www.goatcounter.com/) - [documentation](/docs/analytics/goatcounter.md)
* [Matomo](https://matomo.org/) - [documentation](/docs/analytics/matomo.md)
* [Micro Analytics](https://microanalytics.io/) - [documentation](/docs/analytics/microanalytics.md)
* [Pirsch](https://pirsch.io/) - [documentation](/docs/analytics/pirsch.md)
* [Plausible Analytics](https://plausible.io/) - [documentation](/docs/analytics/plausible.md)
* [Umami](https://umami.is/) - [documentation](/docs/analytics/umami.md)
* [Wide Angle Analytics](https://wideangle.co/) - [documentation](/docs/analytics/wideangle.md)
docs/analytics/pirsch.md
New file
@@ -0,0 +1,6 @@
# Pirsch
```toml
[params.pirsch]
  code = "ABCDE"
```
exampleSite/config.toml
@@ -88,6 +88,10 @@
# id = "ABCDE"
# dnt = "false" # respect DNT tracker, "true" by default
# If you want to use Pirsch(https://pirsch.io) for analytics, add this section
# [params.pirsch]
# code = "ABCDE"
# If you want to implement a Content-Security-Policy, add this section
# [params.csp]
# childsrc = ["'self'"]
layouts/_default/baseof.html
@@ -108,6 +108,10 @@
  {{- partial "analytics/umami" . -}}
  {{ end }}
  {{ if and .Site.Params.pirsch .Site.Params.pirsch.code }}
  {{- partial "analytics/pirsch" . -}}
  {{ end }}
  {{- partial "body/extensions" . -}}
</body>
layouts/partials/analytics/pirsch.html
New file
@@ -0,0 +1,3 @@
<script async defer type="text/javascript" src="https://api.pirsch.io/pirsch.js"
    id="pirschjs"
    data-code="{{ .Site.Params.pirsch.code }}"></script>