Skip to content

Commit

Permalink
Merge pull request #378 from alwaystest/feature/migrateGoogleAnalytics
Browse files Browse the repository at this point in the history
MOD: migrate GoogleAnalytics to gtag.js
  • Loading branch information
LolipopJ authored Jul 5, 2023
2 parents c2dc387 db3dbe5 commit 4559f79
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions layout/_partial/base-head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 68,16 @@
})();
</script>
<% } %>
<!-- 谷歌统计 -->
<!-- Google tag (gtag.js) -->
<% if (theme.google_analytics) { %>
<script async src="https://www.googletagmanager.com/gtag/js?id=<%- theme.google_analytics %>"></script>
<script>
(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');
ga('create', '<%- theme.google_analytics %>', 'auto');
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<%- theme.google_analytics %>');
</script>
<% } %>

</head>

0 comments on commit 4559f79

Please sign in to comment.