MaLuns / hexo-theme-async

一个简单而轻量级的 Hexo 主题。 | A simple, lightweight Hexo theme.
https://hexo-theme-async.imalun.com
MIT License
327 stars 40 forks source link

[Bug]: Google Analytics 代码无效 #64

Closed takosenpai2687 closed 1 year ago

takosenpai2687 commented 1 year ago

使用的 Hexo-Theme-Asycn 版本? | What version of Hexo-Theme-Asycn are you use?

2.0.1

是否修改过主题文件? || Has the theme files been modified?

不是 (No)

使用的浏览器? || What browse are you using?

Chrome

使用的系統? || What operating system are you using?

Windows

问题描述 | Describe the bug

部署在Github Pages的博客,在配置中正确输入了G-XXX格式的tracking id后48小时,Google Analytics依然提示:

您的网站未启用数据收集功能。如果 48 小时之前您就添加了代码,请确保代码设置正确无误。

经查验,网站实际套用的代码为(G-XXXXXXXXXX为tracking id):

<!-- Google Analytics -->
--
  | <script defer>
  | window.ga = window.ga \|\| function () { (ga.q = ga.q \|\| []).push(arguments) };
  | ga.l = +new Date;
  | ga('create', 'G-XXXXXXXXXX', 'auto');
  | ga('send', 'pageview');
  | </script>
  | <script async src='https://www.google-analytics.com/analytics.js'></script>

而GA控制台提供的代码模板为:

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXXX');
</script>

不知道是GA更新了还是我的姿势不对?

出现问题网站 | Website

https://takosenpai2687.github.io

takosenpai2687 commented 1 year ago

补充 _config.async.yml 配置:

# 统计
webAnalytics:  
  enable: true
  baidu:   
  google: G-XXXXXXXXXX
  tencent: 
    sid:
    cid:
MaLuns commented 1 year ago

应该主题里的没更新,在 v2.0.2 中修复了

takosenpai2687 commented 1 year ago

更新后确实解决了,感谢修复!