Skip to content

Commit 36487a7

Browse files
committed
Add support for GoatCounter analytics
1 parent 1c90d80 commit 36487a7

5 files changed

Lines changed: 11 additions & 0 deletions

File tree

backend/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type Config struct {
2323
GoogleClientSecret string `toml:"google_client_secret"`
2424
GoogleRedirectURI string `toml:"google_redirect_uri"`
2525
PlausibleDataDomain string `toml:"plausible_data_domain"`
26+
GoatCounterCode string `toml:"goatcounter_code"`
2627
}
2728

2829
func Read(data string) (Config, error) {

backend/web/layout/base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ type BaseData struct {
1414
CSRFToken string
1515
Toast string
1616

17+
GoatCounterCode string
1718
PlausibleDataDomain string
1819
}

backend/web/layout/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
{{with .PlausibleDataDomain}}
1616
<script src="https://plausible.io/js/script.js" data-domain="{{.}}" defer></script>
1717
{{end}}
18+
{{with .GoatCounterCode}}
19+
<script data-goatcounter="https://{{.}}.goatcounter.com/count" async src="//gc.zgo.at/count.js"></script>
20+
{{end}}
1821
</head>
1922

2023
<body class="sans-serif">

backend/web/util/template.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ func TemplateBaseData(r *http.Request, w http.ResponseWriter) layout.BaseData {
3333
if ok && conf.PlausibleDataDomain != "" {
3434
data.PlausibleDataDomain = conf.PlausibleDataDomain
3535
}
36+
if ok && conf.GoatCounterCode != "" {
37+
data.GoatCounterCode = conf.GoatCounterCode
38+
}
3639

3740
return data
3841
}

bloggulus.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ port = "5000"
2727

2828
# OPTIONAL - Plausible Analytics data domain
2929
# plausible_data_domain = ""
30+
31+
# OPTIONAL - GoatCounter code
32+
# goatcounter_code = ""

0 commit comments

Comments
 (0)