Plausible Analytics

This module add Plausible Analytics for Hugo and HugoPress.

Module
github.com/hugomods/plausible-analytics
GitHub Stars Used By Used By Used By Used By

Installation

Import the Module

hugo.yaml

1module:
2  imports:
3  - path: github.com/hugomods/plausible-analytics

hugo.toml

1[module]
2  [[module.imports]]
3    path = 'github.com/hugomods/plausible-analytics'

hugo.json

1{
2   "module": {
3      "imports": [
4         {
5            "path": "github.com/hugomods/plausible-analytics"
6         }
7      ]
8   }
9}

Import the Script

Please skip this step if your theme supports HugoPress, such as HB Framework themes.

1{{ partial "plausible-analytics/assets/js" . }}

Site Configuration

ParameterTypeRequiredDefaultDescription
endpointstring-https://plausible.ioThe endpoint of Plausible Analytics.
file_downloadsboolean-falseWhether to track file downloads.
outbound_linksboolean-falseWhether to track clicks on outbound links.
localboolean-falseWhen true, track on localhost.

hugo.yaml

1params:
2  plausible_analytics:
3    endpoint: https://plausible.io
4    file_downloads: false
5    local: false
6    outbound_links: false

hugo.toml

1[params]
2  [params.plausible_analytics]
3    endpoint = 'https://plausible.io'
4    file_downloads = false
5    local = false
6    outbound_links = false

hugo.json

 1{
 2   "params": {
 3      "plausible_analytics": {
 4         "endpoint": "https://plausible.io",
 5         "file_downloads": false,
 6         "local": false,
 7         "outbound_links": false
 8      }
 9   }
10}

Page Configuration

You can also override the site configuration on specified pages by setting following parameters on front matter.

ParameterTypeRequiredDefaultDescription
file_downloadsboolean-Site settings.Whether to track file downloads.
outbound_linksboolean-Site settings.Whether to track clicks on outbound links.
analyzeboolean-trueExclude pages from being tracked if false.
1plausible_analytics:
2  analyze: true
3  file_downloads: false
4  outbound_links: false
1[plausible_analytics]
2  analyze = true
3  file_downloads = false
4  outbound_links = false
1{
2   "plausible_analytics": {
3      "analyze": true,
4      "file_downloads": false,
5      "outbound_links": false
6   }
7}