hugo-theme-introduction icon indicating copy to clipboard operation
hugo-theme-introduction copied to clipboard

Accommodate the new Google Analytics 4

Open linhtto opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. The current footnote script accommodates Google Analytics 3 (Universal Analytics) but not the new Google Analytics 4. Google will no longer support Universal Analytics in 2023.

See here.

Describe the solution you'd like

  • Hugo already takes care of this upstream https://gohugo.io/templates/internal/#google-analytics
  • The only change needed is to call {{ template "_internal/google_analytics.html" . }} instead of {{ template "_internal/google_analytics_async.html" . }} inside /layouts/partials/footer/scripts.html. This solution will accommodate both versions of Google Analytics ("G-" IDs will be recognized as GA4, and "UA-" IDs as GA3.

Please let me know if you want me to go ahead and make this change.

linhtto avatar Jun 28 '22 22:06 linhtto

Relatedly, Google Analytics' own instructions say to put the script into the Head section ("Copy the global site tag into the

section of your HTML." and "Copy and paste your entire Analytics page tag immediately after the tag on each page of your website.") but right now the theme adds it in the Body section in footer/scripts.html. Should this be changed? I propose to put it in head/metadata.html instead but let me know if something else makes more sense.

linhtto avatar Jun 29 '22 00:06 linhtto

Sounds good! Please feel free to open a PR for this.

victoriadrake avatar Jul 07 '22 00:07 victoriadrake

It looks like this has been idle a while, so I am marking it as stale. Remove the label or comment if this issue should remain open.

github-actions[bot] avatar Aug 07 '22 00:08 github-actions[bot]

This might be stale, it is needed more not less because time has passed.

kylecordes avatar Aug 07 '22 16:08 kylecordes