Explorar o código

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>
Kilian Kluge %!s(int64=2) %!d(string=hai) anos
pai
achega
5c2476be1c
Modificáronse 3 ficheiros con 4 adicións e 1 borrados
  1. 1 0
      CONTRIBUTORS.md
  2. 2 0
      exampleSite/config.toml
  3. 1 1
      layouts/partials/analytics/plausible.html

+ 1 - 0
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)

+ 2 - 0
exampleSite/config.toml

@@ -55,6 +55,8 @@ customRemoteJS = []
 # [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]

+ 1 - 1
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>