Skip to content

Commit 03adb30

Browse files
committed
fix: Use is:inline for GA4 to prevent Astro transformation
Astro was minifying the gtag script, renaming 'gtag' to 'a'. Google Search Console couldn't recognize the transformed code. Using is:inline preserves the exact script for verification.
1 parent dd69940 commit 03adb30

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/Head.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ const schemaOrg = {
9191
};
9292
---
9393

94-
{/* Google Analytics 4 - must be early in head for Search Console verification */}
95-
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1NZRT4TYL6"></script>
96-
<script>
94+
{/* Google Analytics 4 - is:inline prevents Astro from transforming the script */}
95+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1NZRT4TYL6" is:inline></script>
96+
<script is:inline>
9797
window.dataLayer = window.dataLayer || [];
9898
function gtag(){dataLayer.push(arguments);}
9999
gtag('js', new Date());

0 commit comments

Comments
 (0)