This commit is contained in:
Jerry
2025-05-09 17:57:40 +08:00
6 changed files with 33 additions and 6 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
.DS_Store
.DS_Store
node_modules/

View File

@@ -702,6 +702,12 @@ umami_analytics:
# Umami Cloud (API key) / self-hosted Umami (token)
token:
# https://www.googletagmanager.com/
google_tag_manager:
tag_id:
# optional
domain:
# --------------------------------------
# Advertisement
# --------------------------------------

View File

@@ -54,4 +54,8 @@ div
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src= theme.asset.busuanzi || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
!= partial('includes/third-party/search/index', {}, { cache: true })
!= partial('includes/third-party/search/index', {}, { cache: true })
if (theme.google_tag_manager && theme.google_tag_manager.tag_id)
noscript
iframe(src=`${theme.google_tag_manager.domain ? theme.google_tag_manager.domain : 'https://www.googletagmanager.com'}/ns.html?id=${theme.google_tag_manager.tag_id}` height="0" width="0" style="display:none;visibility:hidden")

View File

@@ -31,4 +31,15 @@ if theme.microsoft_clarity
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "!{theme.microsoft_clarity}");
})(window, document, "clarity", "script", "!{theme.microsoft_clarity}");
if (theme.google_tag_manager && theme.google_tag_manager.tag_id)
script.
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
"!{theme.google_tag_manager.domain ? theme.google_tag_manager.domain : 'https://www.googletagmanager.com'}/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','!{theme.google_tag_manager.tag_id}');
btf.addGlobalFn('pjaxComplete', () => {
dataLayer.push({'event': 'pjaxComplete', 'page_title': document.title, 'page_location': location.href, 'page_path': window.location.pathname});
}, 'google_tag_manager');

View File

@@ -15,16 +15,18 @@
"hexo-theme-butterfly"
],
"repository": {
"type" : "git",
"url" : "https://github.com/jerryc127/hexo-theme-butterfly.git"
"type": "git",
"url": "https://github.com/jerryc127/hexo-theme-butterfly.git"
},
"bugs": {
"url": "https://github.com/jerryc127/hexo-theme-butterfly/issues",
"email": "my@crazywong.com"
},
"dependencies": {
"hexo-renderer-pug": "^3.0.0",
"hexo-renderer-stylus": "^3.0.1",
"hexo-renderer-pug": "^3.0.0"
"hexo-util": "^3.3.0",
"moment-timezone": "^0.5.48"
},
"homepage": "https://butterfly.js.org/",
"author": "Jerry <my@crazywong.com>",

View File

@@ -388,6 +388,10 @@ hexo.extend.filter.register('before_generate', () => {
crisp: {
website_id: null
},
google_tag_manager: {
tag_id: null,
domain: 'https://www.googletagmanager.com'
},
baidu_analytics: null,
google_analytics: null,
cloudflare_analytics: null,