From d4d6698168ca1ac1e0e80b58145a7b3b86f018f2 Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Fri, 16 Jun 2023 10:22:49 +0800 Subject: [PATCH 1/6] add plausible analytics --- config/_default/params.toml | 6 ++++++ layouts/partials/analytics.html | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index c79ad081..f76a41de 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -70,6 +70,12 @@ fingerprintAlgorithm = "sha256" # site = "ABC12345" # domain = "llama.yoursite.com" +[plausible] + enable = false + domain = "llama.yoursite.com" + event = "" + script = "" + [verification] # google = "" # bing = "" diff --git a/layouts/partials/analytics.html b/layouts/partials/analytics.html index f8c7c2c2..a4c3e8ac 100644 --- a/layouts/partials/analytics.html +++ b/layouts/partials/analytics.html @@ -6,5 +6,14 @@ {{ end }} {{ end }} + {{ if site.Params.plausible.enable }} + {{ with site.Params.plausible.domain }} + + {{ end }} + {{ end }} {{ template "_internal/google_analytics.html" . }} -{{ end }} +{{ end }} \ No newline at end of file From cc38c6ed78bbe0073ee255eb1bfe0a0063c557f8 Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Fri, 16 Jun 2023 10:31:44 +0800 Subject: [PATCH 2/6] params add plausible analytics --- config/_default/params.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index f76a41de..edfeb604 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -72,7 +72,7 @@ fingerprintAlgorithm = "sha256" [plausible] enable = false - domain = "llama.yoursite.com" + domain = "blog.yoursite.com" event = "" script = "" From bff55c09b194aa98a4b0bb0ded3839ac435afe75 Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Fri, 16 Jun 2023 11:42:32 +0800 Subject: [PATCH 3/6] docs: add plausible analytics --- exampleSite/content/docs/configuration/index.md | 4 ++++ exampleSite/content/docs/partials/index.md | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index e898deae..8468a307 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -170,6 +170,10 @@ Many of the article defaults here can be overridden on a per article basis by sp |`taxonomy.showTermCount`|`true`|Whether or not the number of articles within a taxonomy term is displayed on the taxonomy listing.| |`fathomAnalytics.site`|_Not set_|The site code generated by Fathom Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`fathomAnalytics.domain`|_Not set_|If using a custom domain with Fathom Analytics, provide it here to serve `script.js` from the custom domain.| +|`plausible.enable`|`false`|Whether to enable Plausible analysis, set `true` to enable.| +|`plausible.domain`|_Not set_|Enter the domain name of the website you want to track. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| +|`plausible.event`|_Not set_|Plausible api event proxy URL. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details.| +|`plausible.script`|_Not set_|Plausible analysis script proxy URL. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details.| |`verification.google`|_Not set_|The site verification string provided by Google to be included in the site metadata.| |`verification.bing`|_Not set_|The site verification string provided by Bing to be included in the site metadata.| |`verification.pinterest`|_Not set_|The site verification string provided by Pinterest to be included in the site metadata.| diff --git a/exampleSite/content/docs/partials/index.md b/exampleSite/content/docs/partials/index.md index abb44d5a..ec282785 100644 --- a/exampleSite/content/docs/partials/index.md +++ b/exampleSite/content/docs/partials/index.md @@ -24,6 +24,19 @@ To enable Fathom Analytics support, simply provide your Fathom site code in the domain = "llama.yoursite.com" ``` +### Plausible Analytics + +To enable Plausible analytics support, simply set `plausible.enable` to `true` in the `config/_default/params.toml` file, and then provide your Plausible site `domain`. If you are using a self-hosted Plausible, or wish to use [proxied analytics](https://plausible.io/docs/proxy/introduction) scripts and event API router, you can also provide additional `event` and `script` configuration values. If you do not provide these two values, the script will load directly with Plausible's default. + +```toml +# config/_default/params.toml + +[plausible] + enable = true + domain = "blog.yoursite.com" + event = "https://stats.dejavu.moe/blog" + script = "https://stats.dejavu.moe/react.min.js" + ### Google Analytics Google Analytics support is provided through the internal Hugo partial. Simply provide the `googleAnalytics` key in the `config/_default/config.toml` file and the script will be added automatically. From 2deaecf5b7a308238e399a63cf3c7a8d14be9992 Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Fri, 16 Jun 2023 11:55:22 +0800 Subject: [PATCH 4/6] fix some spell errors --- exampleSite/content/docs/configuration/index.md | 2 +- exampleSite/content/docs/partials/index.md | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 8468a307..f26fe20b 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -170,7 +170,7 @@ Many of the article defaults here can be overridden on a per article basis by sp |`taxonomy.showTermCount`|`true`|Whether or not the number of articles within a taxonomy term is displayed on the taxonomy listing.| |`fathomAnalytics.site`|_Not set_|The site code generated by Fathom Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`fathomAnalytics.domain`|_Not set_|If using a custom domain with Fathom Analytics, provide it here to serve `script.js` from the custom domain.| -|`plausible.enable`|`false`|Whether to enable Plausible analysis, set `true` to enable.| +|`plausible.enable`|`false`|Whether to enable Plausible analytics, set `true` to enable.| |`plausible.domain`|_Not set_|Enter the domain name of the website you want to track. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`plausible.event`|_Not set_|Plausible api event proxy URL. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details.| |`plausible.script`|_Not set_|Plausible analysis script proxy URL. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details.| diff --git a/exampleSite/content/docs/partials/index.md b/exampleSite/content/docs/partials/index.md index ec282785..39cddc4a 100644 --- a/exampleSite/content/docs/partials/index.md +++ b/exampleSite/content/docs/partials/index.md @@ -34,8 +34,9 @@ To enable Plausible analytics support, simply set `plausible.enable` to `true` i [plausible] enable = true domain = "blog.yoursite.com" - event = "https://stats.dejavu.moe/blog" - script = "https://stats.dejavu.moe/react.min.js" + # event = "" + # script = "" +``` ### Google Analytics From 35ead410c7b465d5ebc7b9c0d484e4c72d3b9369 Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Sun, 25 Jun 2023 15:51:45 +0800 Subject: [PATCH 5/6] refactor: plausible support --- config/_default/params.toml | 7 +++---- exampleSite/content/docs/configuration/index.md | 7 +++---- exampleSite/content/docs/partials/index.md | 7 +++---- layouts/partials/analytics.html | 9 +++------ 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index edfeb604..a9e0167c 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -71,10 +71,9 @@ fingerprintAlgorithm = "sha256" # domain = "llama.yoursite.com" [plausible] - enable = false - domain = "blog.yoursite.com" - event = "" - script = "" + # domain = "blog.yoursite.com" + # event = "" + # script = "" [verification] # google = "" diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index f26fe20b..8df9a132 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -170,10 +170,9 @@ Many of the article defaults here can be overridden on a per article basis by sp |`taxonomy.showTermCount`|`true`|Whether or not the number of articles within a taxonomy term is displayed on the taxonomy listing.| |`fathomAnalytics.site`|_Not set_|The site code generated by Fathom Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`fathomAnalytics.domain`|_Not set_|If using a custom domain with Fathom Analytics, provide it here to serve `script.js` from the custom domain.| -|`plausible.enable`|`false`|Whether to enable Plausible analytics, set `true` to enable.| -|`plausible.domain`|_Not set_|Enter the domain name of the website you want to track. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| -|`plausible.event`|_Not set_|Plausible api event proxy URL. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details.| -|`plausible.script`|_Not set_|Plausible analysis script proxy URL. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details.| +|`plausible.domain`|_Not set_|Enter the domain of the website you want to track. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| +|`plausible.event`|_Not set_|Plausible api event proxied URL. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| +|`plausible.script`|_Not set_|Plausible analysis script proxied URL. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`verification.google`|_Not set_|The site verification string provided by Google to be included in the site metadata.| |`verification.bing`|_Not set_|The site verification string provided by Bing to be included in the site metadata.| |`verification.pinterest`|_Not set_|The site verification string provided by Pinterest to be included in the site metadata.| diff --git a/exampleSite/content/docs/partials/index.md b/exampleSite/content/docs/partials/index.md index 39cddc4a..f2b00b87 100644 --- a/exampleSite/content/docs/partials/index.md +++ b/exampleSite/content/docs/partials/index.md @@ -26,16 +26,15 @@ To enable Fathom Analytics support, simply provide your Fathom site code in the ### Plausible Analytics -To enable Plausible analytics support, simply set `plausible.enable` to `true` in the `config/_default/params.toml` file, and then provide your Plausible site `domain`. If you are using a self-hosted Plausible, or wish to use [proxied analytics](https://plausible.io/docs/proxy/introduction) scripts and event API router, you can also provide additional `event` and `script` configuration values. If you do not provide these two values, the script will load directly with Plausible's default. +To enable Plausible analytics support, simply provide the domain of the website you want to track in the `config/_default/params.toml` file. If you are using a self-hosted Plausible, or wish to use a [proxied analytics](https://plausible.io/docs/proxy/introduction) script and event API router, you can also provide additional `event` and `script` configuration values. If you do not provide these two values, the script will load directly with Plausible's default managed service. Refer to [Using a proxy for analytics](https://plausible.io/docs/proxy/introduction) for more details. ```toml # config/_default/params.toml [plausible] - enable = true domain = "blog.yoursite.com" - # event = "" - # script = "" + event = "https://plausible.yoursite.com/api/event" + script = "https://plausible.yoursite.com/js/script.js" ``` ### Google Analytics diff --git a/layouts/partials/analytics.html b/layouts/partials/analytics.html index a4c3e8ac..012909f2 100644 --- a/layouts/partials/analytics.html +++ b/layouts/partials/analytics.html @@ -6,14 +6,11 @@ {{ end }} {{ end }} - {{ if site.Params.plausible.enable }} - {{ with site.Params.plausible.domain }} - - {{ end }} - {{ end }} + {{ end }} {{ template "_internal/google_analytics.html" . }} {{ end }} \ No newline at end of file From 467ebf9e05f94cede6c88c4095d18c0387cacbde Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Mon, 26 Jun 2023 14:24:39 +0800 Subject: [PATCH 6/6] keep the parameters consistent --- config/_default/params.toml | 2 +- exampleSite/content/docs/configuration/index.md | 6 +++--- exampleSite/content/docs/partials/index.md | 2 +- layouts/partials/analytics.html | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/_default/params.toml b/config/_default/params.toml index a9e0167c..db391cb7 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -70,7 +70,7 @@ fingerprintAlgorithm = "sha256" # site = "ABC12345" # domain = "llama.yoursite.com" -[plausible] +[plausibleAnalytics] # domain = "blog.yoursite.com" # event = "" # script = "" diff --git a/exampleSite/content/docs/configuration/index.md b/exampleSite/content/docs/configuration/index.md index 8df9a132..94b687a5 100644 --- a/exampleSite/content/docs/configuration/index.md +++ b/exampleSite/content/docs/configuration/index.md @@ -170,9 +170,9 @@ Many of the article defaults here can be overridden on a per article basis by sp |`taxonomy.showTermCount`|`true`|Whether or not the number of articles within a taxonomy term is displayed on the taxonomy listing.| |`fathomAnalytics.site`|_Not set_|The site code generated by Fathom Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`fathomAnalytics.domain`|_Not set_|If using a custom domain with Fathom Analytics, provide it here to serve `script.js` from the custom domain.| -|`plausible.domain`|_Not set_|Enter the domain of the website you want to track. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| -|`plausible.event`|_Not set_|Plausible api event proxied URL. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| -|`plausible.script`|_Not set_|Plausible analysis script proxied URL. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| +|`plausibleAnalytics.domain`|_Not set_|Enter the domain of the website you want to track. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| +|`plausibleAnalytics.event`|_Not set_|Plausible api event proxied URL. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| +|`plausibleAnalytics.script`|_Not set_|Plausible analysis script proxied URL. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details.| |`verification.google`|_Not set_|The site verification string provided by Google to be included in the site metadata.| |`verification.bing`|_Not set_|The site verification string provided by Bing to be included in the site metadata.| |`verification.pinterest`|_Not set_|The site verification string provided by Pinterest to be included in the site metadata.| diff --git a/exampleSite/content/docs/partials/index.md b/exampleSite/content/docs/partials/index.md index f2b00b87..17f2987f 100644 --- a/exampleSite/content/docs/partials/index.md +++ b/exampleSite/content/docs/partials/index.md @@ -31,7 +31,7 @@ To enable Plausible analytics support, simply provide the domain of the website ```toml # config/_default/params.toml -[plausible] +[plausibleAnalytics] domain = "blog.yoursite.com" event = "https://plausible.yoursite.com/api/event" script = "https://plausible.yoursite.com/js/script.js" diff --git a/layouts/partials/analytics.html b/layouts/partials/analytics.html index 012909f2..64a2e350 100644 --- a/layouts/partials/analytics.html +++ b/layouts/partials/analytics.html @@ -6,11 +6,11 @@ {{ end }} {{ end }} - {{ with site.Params.plausible.domain }} + {{ with site.Params.plausibleAnalytics.domain }} + data-api="{{ default "https://plausible.io/api/event" site.Params.plausibleAnalytics.event }}" + src="{{ default "https://plausible.io/js/script.js" site.Params.plausibleAnalytics.script }}"> {{ end }} {{ template "_internal/google_analytics.html" . }} {{ end }} \ No newline at end of file