Skip to content

Commit e1a7d51

Browse files
mobeicanyuezkqiang
authored andcommitted
✨ 新增 Umami 访问统计插件 #1055
1 parent 341f576 commit e1a7d51

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

_config.yml

+15
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ web_analytics: # 网页访问统计
258258
google:
259259
measurement_id:
260260

261+
# Umami Analytics,src 和 data-website-id 是必填项,其他可选
262+
# Umami Analytics, src and data-website-id are required, others are optional
263+
umami:
264+
# umami js 文件地址,需要在 umami 后台创建站点后获取
265+
# umami js file url, get after create website in umami
266+
src:
267+
# umami 的 website id,需要在 umami 后台创建站点后获取
268+
# umami website id, get after create website in umami
269+
data_website_id:
270+
# 如果你只想跟踪器跟踪特定的域名,你可以将它们添加到你的跟踪器脚本中。这是一个逗号分隔的域名列表。
271+
# 如果你在一个分阶段、开发的环境中工作,这会很有帮助。避免统计 localhost。
272+
# If you want the tracker to only run on specific domains, you can add them to your tracker script. This is a comma delimited list of domain names.
273+
# Helps if you are working in a staging/development environment. Avoids tracking localhost.
274+
data_domains:
275+
261276
# 腾讯统计的 H5 App ID,开启高级功能才有cid
262277
# Tencent analytics, set APP ID
263278
# See: https://mta.qq.com/h5/manage/ctr_app_manage

layout/_partials/plugins/analytics.ejs

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
</script>
3232
<% } %>
3333
34+
<% if(theme.web_analytics.umami && theme.web_analytics.umami.src && theme.web_analytics.umami.data_website_id) { %>
35+
<!-- Umami Analytics -->
36+
<script async defer src="<%= theme.web_analytics.umami.src %>" data-website-id="<%= theme.web_analytics.umami.data_website_id %>"
37+
<% if (theme.web_analytics.umami.data_domains) { %> data-domains="<%= theme.web_analytics.umami.data_domains %>" <% } %>
38+
<% if (theme.web_analytics.follow_dnt) { %> data-do-not-track="<%= theme.web_analytics.follow_dnt %>" <% } %>
39+
></script>
40+
<% } %>
41+
3442
<% if(theme.web_analytics.tencent && theme.web_analytics.tencent.sid && theme.web_analytics.tencent.cid) { %>
3543
<!-- Tencent Analytics -->
3644
<script async>

0 commit comments

Comments
 (0)