mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-15 21:24:39 -04:00
Add support for Google Analytics v4
This commit is contained in:
parent
02d36f9bc2
commit
95350eb797
@ -92,6 +92,9 @@ respectDoNotTrack
|
|||||||
useSessionStorage
|
useSessionStorage
|
||||||
: Enabling this will disable the use of Cookies and use Session Storage to Store the GA Client ID.
|
: Enabling this will disable the use of Cookies and use Session Storage to Store the GA Client ID.
|
||||||
|
|
||||||
|
{{% warning %}}
|
||||||
|
`useSessionStorage` is not supported when using Google Analytics v4 (gtag.js).
|
||||||
|
{{% /warning %}}
|
||||||
### Instagram
|
### Instagram
|
||||||
|
|
||||||
simple
|
simple
|
||||||
|
@ -27,14 +27,20 @@ While the following internal templates are called similar to partials, they do *
|
|||||||
|
|
||||||
## Google Analytics
|
## Google Analytics
|
||||||
|
|
||||||
Hugo ships with internal templates for Google Analytics tracking, including both synchronous and asynchronous tracking codes.
|
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.
|
||||||
|
|
||||||
### Configure Google Analytics
|
### 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" >}}
|
{{< code-toggle file="config" >}}
|
||||||
googleAnalytics = "UA-123-45"
|
googleAnalytics = "UA-PROPERTY_ID"
|
||||||
|
{{</ code-toggle >}}
|
||||||
|
|
||||||
|
**Google Analytics v4 (gtag.js)**
|
||||||
|
{{< code-toggle file="config" >}}
|
||||||
|
googleAnalytics = "G-MEASUREMENT_ID"
|
||||||
{{</ code-toggle >}}
|
{{</ code-toggle >}}
|
||||||
|
|
||||||
### Use the Google Analytics Template
|
### Use the Google Analytics Template
|
||||||
@ -50,6 +56,8 @@ You can then include the Google Analytics internal template:
|
|||||||
{{ template "_internal/google_analytics_async.html" . }}
|
{{ template "_internal/google_analytics_async.html" . }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
When using Google Analytics v4 use `_internal/google_analytics.html`.
|
||||||
|
|
||||||
A `.Site.GoogleAnalytics` variable is also exposed from the config.
|
A `.Site.GoogleAnalytics` variable is also exposed from the config.
|
||||||
|
|
||||||
## Disqus
|
## Disqus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user