Skip to content

Commit

Permalink
Troubleshoots Google Analytics issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ander94lakx committed Aug 14, 2022
1 parent b63690f commit 1245c1e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
30 changes: 30 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="{{ $.Site.Language }}">
<head>
{{ block "title" . }}
<title>{{ if .IsHome }}{{ $.Site.Title }}{{ else }}{{ .Title }} :: {{ $.Site.Title }}{{ end }}</title>
{{ end }}
{{ partial "head.html" . }}
{{ if and (hugo.IsProduction) (.Site.Params.googleAnalyticsID) }}
{{ partial "analytics-gtag.html" . }}
{{ end }}
</head>
<body class="{{- ( or .Params.color $.Site.Params.ThemeColor ) -}}">
{{ $container := cond ($.Site.Params.FullWidthTheme | default false) "container full" (cond ($.Site.Params.CenterTheme | default false) "container center" "container") }}

<div class="{{- $container -}}{{- cond ($.Site.Params.oneHeadingSize | default true) " headings--one-size" "" }}">

{{ partial "header.html" . }}

<div class="content">
{{ block "main" . }}
{{ end }}
</div>

{{ block "footer" . }}
{{ partial "footer.html" . }}
{{ end }}
</div>

</body>
</html>
9 changes: 9 additions & 0 deletions layouts/partials/analytics-gtag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.GoogleAnalyticsID }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.Params.GoogleAnalyticsID }}');
</script>

0 comments on commit 1245c1e

Please sign in to comment.