Skip to content

Commit

Permalink
✨ Feat: add Baidu, Umami, Plausible, Cloudflare and Splitbee analytic…
Browse files Browse the repository at this point in the history
…s support

resolved #549
  • Loading branch information
Lruihao committed Nov 22, 2024
1 parent f1ba78e commit fb80b8b
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ I don't know why 🤷
- Optimized SEO performance with a correct **SEO SCHEMA** based on JSON-LD
- **[Google Analytics](https://analytics.google.com/analytics)** supported
- **[Fathom Analytics](https://usefathom.com/)** supported
- **[Baidu Analytics](https://tongji.baidu.com/)** supported
- **[Umami Analytics](https://umami.is/)** supported
- **[Plausible Analytics](https://plausible.io/)** supported
- **[Cloudflare Web Analytics](https://www.cloudflare.com/web-analytics)** supported
- **[Splitbee Analytics](https://splitbee.io)** supported
- Search engine **verification** supported (Google, Bing, Yandex, Pinterest, Baidu, 360 and Sogou)
- **CDN** for third-party libraries supported

Expand Down
5 changes: 5 additions & 0 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
- 使用基于 JSON-LD 格式 的 **SEO SCHEMA** 文件进行 SEO 优化
- 支持 **[Google Analytics](https://analytics.google.com/analytics)**
- 支持 **[Fathom Analytics](https://usefathom.com/)**
- 支持 **[百度统计](https://tongji.baidu.com/)**
- 支持 **[Umami Analytics](https://umami.is/)**
- 支持 **[Plausible Analytics](https://plausible.io/)**
- 支持 **[Cloudflare Web Analytics](https://www.cloudflare.com/web-analytics)**
- 支持 **[Splitbee Analytics](https://splitbee.io)**
- 支持搜索引擎的**网站验证** (Google, Bing, Yandex, Pinterest, Baidu, 360 and Sogou)
- 支持所有第三方库的 **CDN**

Expand Down
25 changes: 25 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,31 @@ enableEmoji = true
id = ""
# server url for your tracker if you're self hosting
server = ""
# FixIt 0.3.16 | NEW Baidu Analytics
[params.analytics.baidu]
id = ""
# FixIt 0.3.16 | NEW Umami Analytics
[params.analytics.umami]
data_website_id = ""
src = ""
data_host_url = ""
data_domains = ""
# FixIt 0.3.16 | NEW Plausible Analytics
[params.analytics.plausible]
data_domain = ""
src = ""
# FixIt 0.3.16 | NEW Cloudflare Analytics
[params.analytics.cloudflare]
token = ""
# FixIt 0.3.16 | NEW Splitbee Analytics
[params.analytics.splitbee]
enable = false
# no cookie mode
no_cookie = true
# respect the do not track setting of the browser
do_not_track = true
# token(optional), more info on https://splitbee.io/docs/embed-the-script
data_token = ""

# Cookie consent config
[params.cookieconsent]
Expand Down
2 changes: 1 addition & 1 deletion i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
configurationError = "Configuration Error\nYou haven't configured the FixIt version param correctly yet. See https://fixit.lruihao.cn/documentation/basics/#theme-configuration"
compatibilityError = "Compatibility Error ({{ .From }} -> {{ .To }}):\nYou have an incompatible update. See https://github.com/hugo-fixit/FixIt/releases"
devVersionWarn = "You are using a development version of FixIt. Please consider using a stable version.\nSee https://github.com/hugo-fixit/FixIt/releases"
devEnvWarn = "Current environment is \"development\". The \"comment system\", \"PWA\", \"CDN\" and \"fingerprint\" will be disabled."
devEnvWarn = "Current environment is \"development\". The \"comment system\", \"PWA\", \"CDN\", \"fingerprint\" and \"analytics\" will be disabled."
quicklyUpgrade = "Quickly upgrade use command: "
# === init ===

Expand Down
2 changes: 1 addition & 1 deletion i18n/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
configurationError = "Erreur de configuration\nVous n'avez pas configuré la version de FixIt correctement. Voir https://fixit.lruihao.cn/documentation/basics/#theme-configuration"
compatibilityError = "Erreur de compatibilité ({{ .From }} -> {{ .To }}):\nVous avez une mise à jour incompatible. Voir https://github.com/hugo-fixit/FixIt/releases"
devVersionWarn = "Vous utilisez une version de développement de FixIt. Veuillez considérer l'utilisation d'une version stable.\nVoir https://github.com/hugo-fixit/FixIt/releases"
devEnvWarn = "L'environnement actuel est \"développement\". Le \"système de commentaires\", le \"PWA\", le \"CDN\" et la \"prise d'empreinte\" seront désactivés."
devEnvWarn = "L'environnement actuel est \"développement\". Le \"système de commentaires\", le \"PWA\", le \"CDN\", le \"prise d'empreinte\" et la \"analyses\" seront désactivés."
quicklyUpgrade = "La mise à jour rapide utilise la commande: "
# === init ===

Expand Down
2 changes: 1 addition & 1 deletion i18n/hi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
configurationError = "कन्फ़िग्यरेशन त्रुटि \nआपने फिक्सइट संस्करण पैरामीटर को सही ढंग से कॉन्फ़िगर नहीं किया है।. यह देखें: https://fixit.lruihao.cn/documentation/basics/#theme-configuration"
compatibilityError = "संगतता त्रुटि ({{ .From }} -> {{ .To }}):\nआपके पास एक असंगत अपडेट है. यह देखें: https://github.com/hugo-fixit/FixIt/releases"
devVersionWarn = "आप फिक्सइट के डिवेलपर संस्करण का उपयोग कर रहे हैं। कृपया एक स्थिर संस्करण का उपयोग करने पर विचार करें।\nयह देखें: https://github.com/hugo-fixit/FixIt/releases"
devEnvWarn = "वर्तमान परिवेश \"डिवेलप्मेंट\" का है। \"टिप्पणी प्रणाली\", \"पीडब्ल्यूए\", \"सीडीएन\" और \"फ़िंगरप्रिंट\" अक्षम कर दिए जाएंगे। "
devEnvWarn = "वर्तमान परिवेश \"डिवेलप्मेंट\" का है। \"टिप्पणी प्रणाली\", \"पीडब्ल्यूए\", \"सीडीएन\", \"फ़िंगरप्रिंट\" और \"विश्लेषण\" अक्षम कर दिए जाएंगे।"
quicklyUpgrade = "शीघ्रता से अपग्रेड यह कमांड का उपयोग करें: "
# === init ===

Expand Down
2 changes: 1 addition & 1 deletion i18n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
configurationError = "配置文件错误\n您还没有正确配置 FixIt 的版本参数。参考 https://fixit.lruihao.cn/zh-cn/documentation/basics/#theme-configuration"
compatibilityError = "兼容性错误 ({{ .From }} -> {{ .To }}):\n您进行了一次不兼容的更新。参考 https://github.com/hugo-fixit/FixIt/releases"
devVersionWarn = "您正在使用开发版的 FixIt,请考虑使用稳定版。\n见 https://github.com/hugo-fixit/FixIt/releases"
devEnvWarn = "当前运行环境是“development”。“评论系统”、“PWA”、“CDN”“fingerprint”不会启用。"
devEnvWarn = "当前运行环境是“development”。“评论系统”、“PWA”、“CDN”“fingerprint”和“统计”不会启用。"
quicklyUpgrade = "使用命令快速升级:"
# === init ===

Expand Down
2 changes: 1 addition & 1 deletion i18n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
configurationError = "配置文件錯誤\n您還沒有正確配置 FixIt 的版本參數。參考 https://fixit.lruihao.cn/zh-cn/documentation/basics/#theme-configuration"
compatibilityError = "兼容性錯誤 ({{ .From }} -> {{ .To }}):\n您進行了一次不兼容的更新。参考 https://github.com/hugo-fixit/FixIt/releases"
devVersionWarn = "您正在使用開發版的 FixIt,請考慮使用穩定版。\n見 https://github.com/hugo-fixit/FixIt/releases"
devEnvWarn = "當前運行環境是“development”。“評論系統”、“PWA”、“CDN”“fingerprint”不會啟用。"
devEnvWarn = "當前運行環境是“development”。“評論系統”、“PWA”、“CDN”“fingerprint”和“統計”不會啟用。"
quicklyUpgrade = "使用命令快速升級:"
# === init ===

Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/init/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.16-0ed41783" -}}
{{- .Scratch.Set "version" "v0.3.16-f1ba78ef" -}}
{{- .Scratch.Set "this" dict -}}

{{- partial "init/detection-env.html" . -}}
Expand Down
43 changes: 43 additions & 0 deletions layouts/partials/plugin/analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,47 @@
</script>
{{- dict "Source" ($analytics.fathom.server | default "cdn.usefathom.com" | printf "https://%v/tracker.js") "Async" true "Attr" "id=fathom-script" | partial "plugin/script.html" -}}
{{- end -}}

{{- /* Baidu Analytics */ -}}
{{- with $analytics.baidu.id -}}
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?{{ . }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
{{- end -}}

{{- /* Umami Analytics */ -}}
{{- with $analytics.umami.data_website_id -}}
<script async defer data-website-id="{{ . }}" src="{{ $analytics.umami.src }}" {{ with $analytics.umami.data_host_url }} data-host-url="{{ . }}" {{ end }} {{ with $analytics.umami.data_domains }} data-domains="{{ . }}" {{ end }}></script>
{{- end -}}

{{- /* Plausible Analytics */ -}}
{{- with $analytics.plausible.data_domain -}}
<script async defer data-domain="{{ . }}" src="{{ $analytics.plausible.src }}"></script>
{{- end -}}

{{- /* Cloudflare Analytics */ -}}
{{- with $analytics.cloudflare.token -}}
<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "{{ $analytics.cloudflare.token }}"}'></script>
{{- end -}}

{{- /* Splitbee Analytics */ -}}
{{- if $analytics.splitbee.enable -}}
{{- $attr := "" -}}
{{- if $analytics.splitbee.do_not_track -}}
{{- $attr = printf `%v data-respect-dnt` $attr -}}
{{- end -}}
{{- if $analytics.splitbee.no_cookie -}}
{{- $attr = printf `%v data-no-cookie` $attr -}}
{{- end -}}
{{- with $analytics.splitbee.data_token -}}
{{- $attr = printf `%v data-token="%v"` $attr . -}}
{{- end -}}
<script defer {{ with $attr }} {{ . | safeHTMLAttr }} {{ end }} src="https://cdn.splitbee.io/sb.js"></script>
{{- end -}}
{{- end -}}

0 comments on commit fb80b8b

Please sign in to comment.