diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | exampleSite/config.toml | 5 | ||||
-rw-r--r-- | layouts/partials/analytics.html | 22 |
3 files changed, 14 insertions, 15 deletions
@@ -59,7 +59,7 @@ The title of the like box. This text will be shown while the box is loading. ### Tracking and comments #### analytics -The Google Analytics tracking ID supporting both Universal Analytics and GA4 +The Google Analytics tracking ID supporting both Universal Analytics and GA4. Universal Anylitics will be used by default, unless`params.analytics.type` is set as `GA4`. #### disqus The disqus_thread ID diff --git a/exampleSite/config.toml b/exampleSite/config.toml index b134895..b649bc3 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -20,13 +20,12 @@ paginate = 6 fbPageUrl = "" fbPageTitle = "" - analytics = "" disqus = "" - + custom_css = ["css/custom.css"] [params.analytics] - type="" + type="UA" trackingID = "" [params.copyright] diff --git a/layouts/partials/analytics.html b/layouts/partials/analytics.html index ddeeb3e..aef6667 100644 --- a/layouts/partials/analytics.html +++ b/layouts/partials/analytics.html @@ -1,4 +1,14 @@ -{{ if eq .type "UA" }} +{{ if eq .type "GA4" }} +<!-- GA4 type - Global site tag (gtag.js) - Google Analytics --> +<script async src="https://www.googletagmanager.com/gtag/js?id={{ .trackingID }}"></script> +<script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + + gtag('config', '{{ .trackingID }}'); +</script> +{{ else }} <!-- UA Tracking type Google Analytics Tracking code --> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ @@ -9,14 +19,4 @@ ga('create', '{{ .trackingID }}', 'auto'); ga('send', 'pageview'); </script> -{{ else }} -<!-- GA4 type - Global site tag (gtag.js) - Google Analytics --> -<script async src="https://www.googletagmanager.com/gtag/js?id={{ .trackingID }}"></script> -<script> - window.dataLayer = window.dataLayer || []; - function gtag(){dataLayer.push(arguments);} - gtag('js', new Date()); - - gtag('config', '{{ .trackingID }}'); -</script> {{ end }}
\ No newline at end of file |