Welcome to mirror list, hosted at ThFree Co, Russian Federation.

google-analytics.html « partials « layouts - github.com/zerostaticthemes/hugo-serif-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 296d4af443fb2566e2887d83fc8042fde2b07654 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{{- if .Site.IsServer -}}
<!-- Dont add Google analytics to localhost -->
{{ else }}
{{ $gid := (getenv "HUGO_GOOGLE_ANALYTICS_ID") }}
{{ if $gid }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{- $gid -}}"></script>
<script>
  window.dataLayer = window.dataLayer || [];

  function gtag() {
    dataLayer.push(arguments);
  }
  gtag('js', new Date());
  gtag('config', '{{- $gid -}}');
</script>
{{ else }}
{{ if .Site.Params.google_analytics_id }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{- .Site.Params.google_analytics_id -}}"></script>
<script>
  window.dataLayer = window.dataLayer || [];

  function gtag() {
    dataLayer.push(arguments);
  }
  gtag('js', new Date());
  gtag('config', '{{- .Site.Params.google_analytics_id -}}');
</script>
{{ end }}
{{ end}}
{{ end }}