Fix Google Analytic not showing up for v3 ID (#363)

Signed-off-by: hossainemruz <hossainemruz@gmail.com>
This commit is contained in:
Emruz Hossain 2021-06-28 00:00:23 +06:00 committed by GitHub
parent 091c77360d
commit 14ee45e4a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View file

@ -11,7 +11,13 @@
<!-- ADD GOOGLE ANALYTICS IF ENABLED -->
{{ if site.GoogleAnalytics }}
{{ template "_internal/google_analytics.html" . }}
<!-- Google Analytics v3 ID -->
{{ if hasPrefix site.GoogleAnalytics "UA-"}}
{{ template "_internal/google_analytics_async.html" . }}
{{ else }}
<!-- Google Analytics v4 ID -->
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ end }}
</head>

View file

@ -31,7 +31,13 @@
<!-- Add Google Analytics if enabled in configuration -->
{{ if site.GoogleAnalytics }}
{{ template "_internal/google_analytics.html" . }}
<!-- Google Analytics v3 ID -->
{{ if hasPrefix site.GoogleAnalytics "UA-"}}
{{ template "_internal/google_analytics_async.html" . }}
{{ else }}
<!-- Google Analytics v4 ID -->
{{ template "_internal/google_analytics.html" . }}
{{ end }}
{{ end }}
</head>
<body data-spy="scroll" data-target="#top-navbar" data-offset="100">

View file

@ -5,7 +5,7 @@
<!-- List all the pages. It uses the sidebar menu to discover the page order. -->
{{ $pages := slice }}
{{ if isset site "Menus" }}
{{ if isset site.Menus "sidebar" }}
{{ $pages = partial "helpers/get-pages.html" site.Menus.sidebar }}
{{ end }}