Adding support for Google Analytics 4 (#149)
1 files added
2 files modified
| | |
| | | googleAnalytics = "UA-123-45" |
| | | ``` |
| | | |
| | | To use the modern Google Analytics 4, include the following under `[params]` replacing the id with your own. |
| | | |
| | | ```toml |
| | | [params] |
| | | gtagId = "G-XXXXXXXXXX" |
| | | ``` |
| | | |
| | | ### Simple Analytics |
| | | |
| | | To use Simple Analytics, it has to be enabled by setting the parameter to true. If you are using a custom subdomain to evade Adblockers, then specify the URL without a trailing slash. |
| | |
| | | {{- partial "medium-zoom.html" . -}} |
| | | {{- partial "math.html" . -}} |
| | | {{- template "_internal/google_analytics_async.html" . -}} |
| | | |
| | | {{- if and (hugo.IsProduction) (.Site.Params.gtagId) -}} |
| | | {{ partial "google-analytics-gtag-async.html" . }} |
| | | {{- end -}} |
| New file |
| | |
| | | <!-- Global site tag (gtag.js) - Google Analytics --> |
| | | <script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.gtagId }}"></script> |
| | | <script> |
| | | window.dataLayer = window.dataLayer || []; |
| | | function gtag(){dataLayer.push(arguments);} |
| | | gtag('js', new Date()); |
| | | gtag('config', '{{ .Site.Params.gtagId }}'); |
| | | </script> |