diff --git a/content/en/templates/internal.md b/content/en/templates/internal.md index 00e8ef084..88d71baae 100644 --- a/content/en/templates/internal.md +++ b/content/en/templates/internal.md @@ -27,31 +27,40 @@ While the following internal templates are called similar to partials, they do * ## Google Analytics -Hugo ships with internal templates for Google Analytics tracking, including both synchronous and asynchronous tracking codes. As well as support for both v3 and v4 of Google Analytics. +Hugo ships with internal templates supporting Google Analytics, both [Google Analytics 4][GA4] (GA4) and Universal Analytics. + +**Note:** Universal Analytics are deprecated. For details, see [Universal Analytics will be going away][]. + +[GA4]: https://support.google.com/analytics/answer/10089681 +[Universal Analytics will be going away]: https://support.google.com/analytics/answer/11583528 ### Configure Google Analytics -Provide your tracking id in your configuration file: +Provide your tracking ID in your configuration file: -**Google Analytics v3 (analytics.js)** -{{< code-toggle file="config" >}} -googleAnalytics = "UA-PROPERTY_ID" -{{}} - -**Google Analytics v4 (gtag.js)** +**Google Analytics 4 (gtag.js)** {{< code-toggle file="config" >}} googleAnalytics = "G-MEASUREMENT_ID" {{}} +**Google Universal Analytics (analytics.js)** +{{< code-toggle file="config" >}} +googleAnalytics = "UA-PROPERTY_ID" +{{}} + ### Use the Google Analytics Template -You can then include the Google Analytics internal template your template: +You can then include the Google Analytics internal template: -```go-html-template -{{ if hugo.IsProduction }} - {{ template "_internal/google_analytics.html" . }} -{{ end }} - ``` +``` +{{ template "_internal/google_analytics_async.html" . }} +``` + +**Note:** The async template is _not_ suitable for Google Analytics 4. + +``` +{{ template "_internal/google_analytics.html" . }} +``` If you want to create your own template, you can access the configured ID with `{{ site.Config.Services.GoogleAnalytics.ID }}`.