mirror of
https://github.com/13hannes11/hugo-coder-timeline.git
synced 2024-09-04 00:50:58 +02:00
Add abbility to use Google Tag Manager for analytics (#514)
* Add ability to embed custom code to <head> * add myself to CONTRIBUTORS.md * implement dedicated template for Google Tag Manager * move google tag manager to bottom of the body tag
This commit is contained in:
@@ -147,6 +147,10 @@
|
||||
{{ if and .Site.Params.matomo .Site.Params.matomo.serverURL }}
|
||||
{{- partial "analytics/matomo" . -}}
|
||||
{{ end }}
|
||||
|
||||
{{ if and .Site.Params.googleTagManager .Site.Params.googleTagManager.id }}
|
||||
{{- partial "analytics/googletagmanager" . -}}
|
||||
{{ end }}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
9
layouts/partials/analytics/googletagmanager.html
Normal file
9
layouts/partials/analytics/googletagmanager.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $.Site.Params.googleTagManager.id }}"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '{{ $.Site.Params.googleTagManager.id }}');
|
||||
</script>
|
||||
Reference in New Issue
Block a user