Skip to content

Commit 42884ee

Browse files
Copilotgarrytrinder
andcommitted
Add Microsoft Clarity analytics script to Layout.astro
Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
1 parent 2b262b7 commit 42884ee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/layouts/Layout.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface Props {
1010
const { title, description = 'Dev Proxy - Simulate API behaviors for testing and development', image } = Astro.props;
1111
const canonicalURL = new URL(Astro.url.pathname, Astro.site ?? 'https://devproxy.net');
1212
const ogImage = image ? new URL(image, Astro.site ?? 'https://devproxy.net').href : undefined;
13+
const clarityProjectId = import.meta.env.PUBLIC_CLARITY_PROJECT_ID;
1314
---
1415

1516
<!doctype html>
@@ -45,6 +46,15 @@ const ogImage = image ? new URL(image, Astro.site ?? 'https://devproxy.net').hre
4546
}
4647
})();
4748
</script>
49+
{clarityProjectId && (
50+
<script is:inline define:vars={{ clarityProjectId }}>
51+
(function(c,l,a,r,i,t,y){
52+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
53+
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
54+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
55+
})(window, document, "clarity", "script", clarityProjectId);
56+
</script>
57+
)}
4858
</head>
4959
<body class="min-h-screen flex flex-col">
5060
<nav class="border-b sticky top-0 z-50 backdrop-blur-sm" style="border-color: var(--border-primary); background: var(--bg-nav);">

0 commit comments

Comments
 (0)