Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
takosenpai2687 opened this issue Feb 9, 2023 · 3 comments
Closed

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

takosenpai2687 opened this issue Feb 9, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@takosenpai2687
Copy link

使用的 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
Copy link
Author

补充 _config.async.yml 配置:

# 统计
webAnalytics:  
  enable: true
  baidu:   
  google: G-XXXXXXXXXX
  tencent: 
    sid:
    cid:

@MaLuns MaLuns added the bug Something isn't working label Feb 10, 2023
@MaLuns MaLuns self-assigned this Feb 10, 2023
MaLuns pushed a commit that referenced this issue Feb 10, 2023
@MaLuns
Copy link
Owner

MaLuns commented Feb 10, 2023

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

@takosenpai2687
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants