forked from drowl87/hextra_mirror

* chore: support `services.googleAnalytics.ID` and deprecate `site.googleAnalytics` * chore: remove warning
20 lines
639 B
HTML
20 lines
639 B
HTML
{{/* site.GoogleAnalytics is deprecated in Hugo v0.120.0 */}}
|
|
{{/* it will be removed in a future version */}}
|
|
{{- $gtagID := "" -}}
|
|
{{- with site.GoogleAnalytics -}}{{ $gtagID = . }}{{- end -}}
|
|
{{- with site.Config.Services.GoogleAnalytics.ID -}}{{ $gtagID = . }}{{- end -}}
|
|
|
|
{{- with $gtagID }}
|
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
|
<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 -}}
|