From 5c2476be1c29563b6dd06c15fb9206d2ca50efae Mon Sep 17 00:00:00 2001
From: Kilian Kluge <32523967+ionicsolutions@users.noreply.github.com>
Date: Tue, 07 Feb 2023 23:44:47 +0000
Subject: [PATCH] Add outbound links and file downloads tracking for plausible.io (#774)

---
 exampleSite/config.toml                   |    2 ++
 layouts/partials/analytics/plausible.html |    2 +-
 CONTRIBUTORS.md                           |    1 +
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index addbcf0..9a79754 100644
--- a/CONTRIBUTORS.md
+++ b/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)
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 27c99b9..230b296 100644
--- a/exampleSite/config.toml
+++ b/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]
diff --git a/layouts/partials/analytics/plausible.html b/layouts/partials/analytics/plausible.html
index 6907070..28450c0 100644
--- a/layouts/partials/analytics/plausible.html
+++ b/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>

--
Gitblit v1.10.0