From 3be5a58a7c05c5e2fff0bfdd4ae3f7ab0435a64f Mon Sep 17 00:00:00 2001 From: JY Hsu Date: Wed, 27 Nov 2024 07:59:35 +0800 Subject: [PATCH] Fix google analytics feature (#989) * fix: Fix google analytics * fix: Change respectDoNotTrack in GA html template --------- Co-authored-by: Emruz Hossain --- layouts/partials/analytics.html | 4 +--- layouts/partials/google_analytics.html | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 layouts/partials/google_analytics.html diff --git a/layouts/partials/analytics.html b/layouts/partials/analytics.html index fc5abb5..58e83f5 100644 --- a/layouts/partials/analytics.html +++ b/layouts/partials/analytics.html @@ -4,9 +4,7 @@ {{ with .services }} {{ with .google }} - {{ $privacyConfig:= dict (slice "Site" "Config" "Privacy" "GoogleAnalytics") $.Site.Config.Privacy.GoogleAnalytics }} - {{ $analyticsConfig := dict (slice "Site" "Config" "Services" "GoogleAnalytics" "ID") .id }} - {{ template "_internal/google_analytics.html" (merge $privacyConfig $analyticsConfig) }} + {{ partial "google_analytics.html" . }} {{ end }} diff --git a/layouts/partials/google_analytics.html b/layouts/partials/google_analytics.html new file mode 100644 index 0000000..4d451c1 --- /dev/null +++ b/layouts/partials/google_analytics.html @@ -0,0 +1,22 @@ +{{ if site.Params.features.analytics.enabled }} + {{- with site.Params.features.analytics.services.google.id }} + {{- if strings.HasPrefix (lower .) "ua-" }} + {{- warnf "Google Analytics 4 (GA4) replaced Google Universal Analytics (UA) effective 1 July 2023. See https://support.google.com/analytics/answer/11583528. Create a GA4 property and data stream, then replace the Google Analytics ID in your site configuration with the new value." }} + {{- else }} + + + {{- end }} + {{- end }} +{{- end -}} \ No newline at end of file