mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-13 16:46:09 -04:00
Migrate from analytics.js to gtag.js
We should move this to the internal Hugo template when tested.
This commit is contained in:
parent
64a29b6cbc
commit
5571673f08
@ -34,7 +34,7 @@
|
|||||||
{{- 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 "gtag" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
|
||||||
|
10
themes/gohugoioTheme/layouts/partials/gtag.html
Normal file
10
themes/gohugoioTheme/layouts/partials/gtag.html
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{{ with .Site.GoogleAnalytics }}
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
|
||||||
|
gtag('config', '{{ . }}');
|
||||||
|
</script>
|
||||||
|
{{ end }}
|
Loading…
x
Reference in New Issue
Block a user