Skip to content

Commit 9b632af

Browse files
feat: Add google analytics
1 parent 8c77e9c commit 9b632af

6 files changed

Lines changed: 17 additions & 2 deletions

File tree

hugo_root/hugo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ ShowReadingTime = true
4747
ShowPostNavLinks = true
4848
ShowCodeCopyButtons = true
4949

50+
[params.analytics.google]
51+
SiteVerificationTag = "G-NPJY8ZT1P0"
52+
5053
[outputs]
5154
home = [ "HTML", "RSS", "JSON" ]
5255

hugo_root/layouts/_markup/render-codeblock-mermaid.html renamed to hugo_root/layouts/_default/_markup/render-codeblock-mermaid.html

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
mermaid.initialize({ startOnLoad: true });
55
</script>
66
{{ end }}
7+
{{ template "_internal/google_analytics.html" . }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- $gaID := .Site.GoogleAnalytics -}}
2+
{{- if and (eq hugo.Environment "production") $gaID -}}
3+
<!-- Google tag (gtag.js) -->
4+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $gaID }}"></script>
5+
<script>
6+
window.dataLayer = window.dataLayer || [];
7+
function gtag(){dataLayer.push(arguments);}
8+
gtag('js', new Date());
9+
gtag('config', '{{ $gaID }}');
10+
</script>
11+
{{- end -}}

vault

Submodule vault updated from 4657ba1 to fe54e31

0 commit comments

Comments
 (0)