Browse Source

Update google-analytics

Fechin 6 years ago
parent
commit
67293d0c02
2 changed files with 18 additions and 16 deletions
  1. 9 6
      _config.yml
  2. 9 10
      layout/_partial/google-analytics.ejs

+ 9 - 6
_config.yml

@@ -19,20 +19,23 @@ welcome_cover: # /img/welcome-cover.jpg
 # 默认文章封面图
 cover: /img/cover.jpg
 
+# 是否关闭默认滚动条
+scrollbar: true
+
 # Gitalk 评论插件(https://github.com/gitalk/gitalk)
 gitalk:
     # 是否自动展开评论框
     autoExpand: false
     # 应用编号
-    clientID: ''
+    clientID: 'a396afe529734b15300f'
     # 应用秘钥
-    clientSecret: ''
+    clientSecret: '0ae7c1790f9a5cbc2b7339c12a82d58fe58f9567'
     # issue仓库名
-    repo: ''
+    repo: 'fechin.github.io'
     # Github名
-    owner: ''
+    owner: 'Fechin'
     # Github名
-    admin: ['']
+    admin: ['Fechin']
     # Ensure uniqueness and length less than 50
     id: location.pathname
     # Facebook-like distraction free mode
@@ -42,7 +45,7 @@ gitalk:
 keywords: Fechin
 
 # 要使用google_analytics进行统计的话,这里需要配置ID
-google_analytics: 
+google_analytics: UA-69833742-2
 
 # 网站ico
 favicon: /img/favicon.png

+ 9 - 10
layout/_partial/google-analytics.ejs

@@ -1,13 +1,12 @@
 <% if (theme.google_analytics){ %>
-<!-- Google Analytics -->
-<script type="text/javascript">
-  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
-  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
-  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
-  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+    <!-- Global site tag (gtag.js) - Google Analytics -->
+    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-69833742-2"></script>
+    <script>
+      window.dataLayer = window.dataLayer || [];
+      function gtag(){dataLayer.push(arguments);}
+      gtag('js', new Date());
 
-  ga('create', '<%= theme.google_analytics %>', 'auto');
-  ga('send', 'pageview');
-</script>
-<!-- End Google Analytics -->
+      gtag('config', '<%=theme.google_analytics%>');
+    </script>
+    <!-- End Google Analytics -->
 <% } %>