try and fix g-analytics

make use of gtag code provided by g-analytics console as a partial here
This commit is contained in:
kirk 2022-04-05 00:00:50 -05:00
parent a711406964
commit 698c637299
2 changed files with 12 additions and 3 deletions

View File

@ -19,7 +19,7 @@
{{ partial "site-style.html" . }} {{ partial "site-style.html" . }}
{{ partial "site-scripts.html" . }} {{ partial "site-scripts.html" . }}
{{ block "favicon" . }} {{ block "favicon" . }}
{{ partialCached "site-favicon.html" . }} {{ partialCached "site-favicon.html" . }}
{{ end }} {{ end }}
@ -30,14 +30,14 @@
<link href="{{ .RelPermalink }}" rel="feed" type="application/rss+xml" title="{{ $.Site.Title }}" /> <link href="{{ .RelPermalink }}" rel="feed" type="application/rss+xml" title="{{ $.Site.Title }}" />
{{ end }} {{ end }}
{{ end }} {{ end }}
{{/* NOTE: These Hugo Internal Templates can be found starting at https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates */}} {{/* NOTE: These Hugo Internal Templates can be found starting at https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates */}}
{{- template "_internal/opengraph.html" . -}} {{- template "_internal/opengraph.html" . -}}
{{- template "_internal/schema.html" . -}} {{- template "_internal/schema.html" . -}}
{{- template "_internal/twitter_cards.html" . -}} {{- template "_internal/twitter_cards.html" . -}}
{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} {{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }}
{{ template "_internal/google_analytics_async.html" . }} {{ partial "analytics-gtag.html" . }}
{{ end }} {{ end }}
{{ block "head" . }}{{ partial "head-additions.html" . }}{{ end }} {{ block "head" . }}{{ partial "head-additions.html" . }}{{ end }}
</head> </head>

View File

@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.GoogleAnalytics }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ .Site.GoogleAnalytics }}');
</script>