From 34ac982a4bf9558ad0734ec49a09c3b1cd6ef6ed Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 11 Aug 2020 21:02:49 +0200 Subject: [PATCH] Add support for plausible analytics (#382) * Add myself to contributors.md * Add plausible config to example * Add plausible to base layout * Add plausible analytics snippet * Remove unneeded part of snippet * Add plausible config to stackbit --- CONTRIBUTORS.md | 1 + exampleSite/config.toml | 6 ++++++ layouts/_default/baseof.html | 4 ++++ layouts/partials/analytics/plausible.html | 1 + stackbit.yaml | 10 ++++++++++ 5 files changed, 22 insertions(+) create mode 100644 layouts/partials/analytics/plausible.html diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d51156b..b992ca2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -71,3 +71,4 @@ - [Endormi](https://endormi.io) - [Rajiv Ranjan Singh](https://iamrajiv.github.io/) - [Pakhomov Alexander](https://github.com/PakhomovAlexander) +- [Rhys Perry](https://rhysperry.com) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index d2e54a2..c95ec45 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -60,6 +60,12 @@ disqusShortname = "yourdiscussshortname" siteID = "ABCDE" # Default value is cdn.usefathom.com, overwrite this if you are self-hosting serverURL = "analytics.example.com" + +# If you want to use plausible(https://plausible.io) for analytics, add this section +[params.plausibleAnalytics] + domain = "example.com" + # Default value is plausible.io, overwrite this if you are self-hosting or using a custom domain + serverURL = "analytics.example.com" [taxonomies] category = "categories" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 825fccd..389275d 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -127,6 +127,10 @@ {{- partial "analytics/fathom" . -}} {{ end }} + {{ if and .Site.Params.plausibleAnalytics .Site.Params.plausibleAnalytics.domain }} + {{- partial "analytics/plausible" . -}} + {{ end }} + diff --git a/layouts/partials/analytics/plausible.html b/layouts/partials/analytics/plausible.html new file mode 100644 index 0000000..d36ba4b --- /dev/null +++ b/layouts/partials/analytics/plausible.html @@ -0,0 +1 @@ + diff --git a/stackbit.yaml b/stackbit.yaml index dd3592f..1050376 100644 --- a/stackbit.yaml +++ b/stackbit.yaml @@ -114,6 +114,16 @@ models: - type: string name: serverURL label: URL for Fathom Analytics + - type: object + name: plausibleAnalytics + label: Plausible Analytics (optional) + fields: + - type: string + name: domain + label: Website domain for Plausible Analytics + - type: string + name: serverURL + label: URL for Plausible Analytics - type: object name: languages fields: