summaryrefslogtreecommitdiff
path: root/src/components/Analytics.astro
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2025-06-15 13:44:39 +0200
committerYuval Adam <_@yuv.al>2025-06-15 13:44:39 +0200
commitdd100d4c821aae71f4a43b10843c74f14480bbc0 (patch)
tree6739853a863b26d0a5896796efeb43e27b219586 /src/components/Analytics.astro
parent2e0755cc68e14bda95abe9472754ae5f4e760a04 (diff)
parentabee8fa7e82e66765ca8b513f9dc1a7bac814779 (diff)
Merge remote-tracking branch 'v2/main'
Diffstat (limited to 'src/components/Analytics.astro')
-rw-r--r--src/components/Analytics.astro33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/components/Analytics.astro b/src/components/Analytics.astro
new file mode 100644
index 0000000..0352bea
--- /dev/null
+++ b/src/components/Analytics.astro
@@ -0,0 +1,33 @@
+---
+import { analytics } from "../config/analytics";
+
+const GOOGLE_ANALYTICS_ID = analytics.googleAnalyticsId;
+const FATHOM_ANALYTICS_ID = analytics.fathomAnalyticsId;
+---
+
+{
+ GOOGLE_ANALYTICS_ID && (
+ <script
+ async
+ src={`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_ID}`}
+ />
+ <script define:vars={{ GOOGLE_ANALYTICS_ID }} is:inline>
+ window.dataLayer = window.dataLayer || [];
+ function gtag() {
+ dataLayer.push(arguments);
+ }
+ gtag("js", new Date());
+ gtag("config", GOOGLE_ANALYTICS_ID);
+ </script>
+ )
+}
+{
+ FATHOM_ANALYTICS_ID && (
+ <script
+ src="https://cdn.usefathom.com/script.js"
+ data-site={FATHOM_ANALYTICS_ID}
+ defer
+ />
+ )
+}
+