From f78a7b2f98dab5890ce7c271a0f1d9a29d6ae4c3 Mon Sep 17 00:00:00 2001 From: Dmitry Kolosov Date: Sun, 11 Apr 2021 17:00:58 +0300 Subject: [PATCH] add support for GA v4 #84 --- layouts/partials/head.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a4ec55c..d45f11b 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -39,8 +39,12 @@ --> -{{ if eq (getenv "HUGO_ENV") "production" | or (eq .Site.Params.env "production") }} - {{ template "_internal/google_analytics_async.html" . }} +{{ if and (.Site.GoogleAnalytics) (or (eq (getenv "HUGO_ENV") "production") (eq .Site.Params.env "production")) }} + {{ if hasPrefix .Site.GoogleAnalytics "UA-" }} + {{ template "_internal/google_analytics_async.html" . }} + {{ else }} + {{ template "_internal/google_analytics.html" . }} + {{ end }} {{ end }} {{ partial "head-extra.html" . }}