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

Kilian Kluge
08.44.2023 5c2476be1c29563b6dd06c15fb9206d2ca50efae
Add outbound links and file downloads tracking for plausible.io (#774)

### 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

Configuration options to activate [outbound link click
tracking](https://plausible.io/docs/outbound-link-click-tracking) and
[file downloads
tracking](https://plausible.io/docs/file-downloads-tracking).

These are two standard options for Plausible that are convenient and
useful in many circumstances.

### Issues Resolved

List any existing issues this pull request resolves.

### 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

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

---------

Co-authored-by: Luiz F. A. de Prá <luizdepra@users.noreply.github.com>
3 files modified
5 ■■■■ changed files
CONTRIBUTORS.md 1 ●●●● patch | view | raw | blame | history
exampleSite/config.toml 2 ●●●●● patch | view | raw | blame | history
layouts/partials/analytics/plausible.html 2 ●●● patch | view | raw | blame | history
CONTRIBUTORS.md
@@ -125,4 +125,5 @@
- [Martin Hellspong](https://github.com/marhel)
- [Robert Tucker](https://github.com/robertwtucker)
- [Michał Pawlik](https://michalp.net)
- [Kilian Kluge](https://github.com/ionicsolutions)
- [Jaroslaw Rozanski](https://jarekrozanski.eu)
exampleSite/config.toml
@@ -55,6 +55,8 @@
# [params.plausibleAnalytics]
# domain = "example.com"
# serverURL = "analytics.example.com" # Default value is plausible.io, overwrite this if you are self-hosting or using a custom domain
# outboundLinksTracking = true
# fileDownloadsTracking = true
# If you want to use goatcounter(https://goatcounter.com) for analytics, add this section
# [params.goatCounter]
layouts/partials/analytics/plausible.html
@@ -1 +1 @@
<script async defer data-domain="{{ .Site.Params.plausibleAnalytics.domain }}" src="https://{{ .Site.Params.plausibleAnalytics.serverURL | default "plausible.io" }}/js/script.js"></script>
<script async defer data-domain="{{ .Site.Params.plausibleAnalytics.domain }}" src="https://{{ .Site.Params.plausibleAnalytics.serverURL | default "plausible.io" }}/js/script{{if .Site.Params.plausibleAnalytics.fileDownloadsTracking}}.file-downloads{{end}}{{if .Site.Params.plausibleAnalytics.outboundLinksTracking}}.outbound-links{{end}}.js"></script>