diff options
author | Nick Desaulniers <nickdesaulniers@users.noreply.github.com> | 2023-02-11 02:43:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-11 02:43:00 +0300 |
commit | be22e9c1e61a228441c5eeeaf1861f10a714f10c (patch) | |
tree | 4df413530d38c786ada1c0b6ad9feff236353f43 /layouts | |
parent | 06215b5fadb0befe2cd16220d696a8bbcf15cb06 (diff) |
* Support Google Analytics 4 using hugo internal template
Use https://gohugo.io/templates/internal/#google-analytics
in footer partial. Update sample-config.toml; googleAnalytics
now needs to be top level rather than under [params] for the
internal template to work. This might be a concern for folks
upgrading their Hugo-Octopress theme.
Fixes: #75
* remove duplicate google analytics tag from header
It's already in the footer, and
https://gohugo.io/templates/internal/#use-the-google-analytics-template
states that "The async template is not suitable for Google Analytics 4."
which is the non-depracated version of GA.
Keep the sync script in the footer to not block page loading.
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/footer.html | 9 | ||||
-rwxr-xr-x | layouts/partials/header.html | 3 |
2 files changed, 1 insertions, 11 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 4817304..6569b9c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -26,13 +26,6 @@ {{ end }} <!-- End Piwik Code --> - {{ with .Site.Params.googleAnalytics }} - <script> - var _gaq=[['_setAccount','{{ . }}'],['_trackPageview']]; - (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0]; - g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js'; - s.parentNode.insertBefore(g,s)}(document,'script')); - </script> - {{ end }} + {{ template "_internal/google_analytics.html" . }} </body> </html> diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 6294536..2ebd50a 100755 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -51,9 +51,6 @@ <!-- Generator version for usage tracking --> {{ hugo.Generator }} - <!-- Google Analytics --> - {{ template "_internal/google_analytics_async.html" . }} - <!-- Enable Twitter card --> {{ with .Site.Params.twitterCardEnabled }} {{ partial "custom_twitter_card.html" $ }} |