mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2025-05-13 14:44:28 -04:00
fix/googleanalytics: add dynamic Google Analytics partial using params
This commit is contained in:
parent
7cf752f864
commit
c3b217aad1
1 changed files with 10 additions and 0 deletions
10
layouts/partials/google_analytics.html
Normal file
10
layouts/partials/google_analytics.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{{- $gaID := .Site.Params.services.googleAnalytics.id }}
|
||||||
|
{{- if and (eq .Site.Params.env "production") $gaID }}
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $gaID }}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag() { dataLayer.push(arguments); }
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', '{{ $gaID }}');
|
||||||
|
</script>
|
||||||
|
{{- end }}
|
Loading…
Add table
Add a link
Reference in a new issue