-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathanalytics.html
22 lines (20 loc) · 1.25 KB
/
analytics.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{{- if eq hugo.Environment "production" }}
{{- if not site.Params.Privacy.GoogleTagManager.Disable }}{{/* First check GTM */}}
{{- with site.Params.Services.GoogleTagManager }}
{{- $gtmParams := dict "gtmCode" (.ID) -}}
{{- $gtmParams = merge $gtmParams (dict "respectDoNotTrack" site.Params.Privacy.GoogleTagManager.RespectDoNotTrack | default true) }}
{{- $gtmScript := slice -}}
{{- $gtmScript = $gtmScript | append (resources.Get "js/gtm.js") -}}
{{- $gtmScript = $gtmScript | resources.Concat "js/analytics.js" -}}
{{- $gtmScript = $gtmScript | js.Build (dict "format" "iife" "target" "es2015" "minify" true "params" $gtmParams) -}}
{{- if site.Params.assets.disable_fingerprinting }}
<script src="{{ $gtmScript.RelPermalink }}"></script>
{{- else -}}
{{- $gtmScript = $gtmScript | fingerprint -}}
<script src="{{ $gtmScript.RelPermalink }}" integrity="{{ $gtmScript.Data.Integrity }}" crossorigin="anonymous"></script>
{{- end -}}
{{- end -}}
{{ else }}{{/* If GTM is disabled delegate the rest to Hugo */}}
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ end }}