Skip to content

Commit

Permalink
feat: Add google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
nafiesl committed Nov 10, 2024
1 parent d73a82c commit c3f1a0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion layouts/index.headers
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'; frame-ancestors https://jamstackthemes.dev; manifest-src 'self'; connect-src 'self' https://*.goatcounter.com/count; frame-src youtube.com www.youtube.com; font-src 'self'; img-src 'self' data: https://i.giphy.com; script-src 'self' https://gc.zgo.at 'unsafe-inline'; style-src 'self' 'unsafe-inline';
Content-Security-Policy: default-src 'self'; frame-ancestors https://jamstackthemes.dev; manifest-src 'self'; connect-src 'self' https://*.goatcounter.com/count https://www.google-analytics.com/g/collect; frame-src youtube.com www.youtube.com; font-src 'self'; img-src 'self' data: https://i.giphy.com; script-src 'self' https://gc.zgo.at https://www.googletagmanager.com 'unsafe-inline'; style-src 'self' 'unsafe-inline';
X-Frame-Options: SAMEORIGIN
Referrer-Policy: strict-origin
Permissions-Policy: geolocation=(self), microphone=(), camera=()
Expand Down
11 changes: 11 additions & 0 deletions layouts/partials/head/script-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@
<link href="https://www.googletagmanager.com" rel="preconnect" crossorigin>
<link rel="dns-prefetch" href="https://www.googletagmanager.com">
{{ end }}

<!-- Google tag (gtag.js) -->
{{ $googleTagId := getenv "HUGO_PARAMS_GOOGLE_TAG_ID" | default "0000" }}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ $googleTagId }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ $googleTagId }}');
</script>

0 comments on commit c3f1a0f

Please sign in to comment.