Skip to content

Commit 4a9ad28

Browse files
committed
add GTM snippets via starlight skiplink override
1 parent e26f3d8 commit 4a9ad28

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default defineConfig({
6363
components: {
6464
Head: "./src/components/Head.astro",
6565
Footer: "./src/components/Footer.astro",
66+
SkipLink: "./src/components/SkipLink.astro",
6667
},
6768
editLink: {
6869
baseUrl: `${repo}edit/main/`,

src/components/Head.astro

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,20 @@ import JsonLD from "./JsonLD.astro";
44
---
55

66
<Default />
7+
8+
<!-- Google Tag Manager -->
9+
<script is:inline>
10+
(function (w, d, s, l, i) {
11+
w[l] = w[l] || [];
12+
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
13+
var f = d.getElementsByTagName(s)[0],
14+
j = d.createElement(s),
15+
dl = l != "dataLayer" ? "&l=" + l : "";
16+
j.async = true;
17+
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
18+
f.parentNode.insertBefore(j, f);
19+
})(window, document, "script", "dataLayer", "GTM-PR4QP6KH");
20+
</script>
21+
<!-- End Google Tag Manager -->
22+
723
<JsonLD />

src/components/SkipLink.astro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
import Default from "@astrojs/starlight/components/SkipLink.astro";
3+
---
4+
5+
<!-- Google Tag Manager (noscript) -->
6+
<noscript>
7+
<iframe
8+
src="https://www.googletagmanager.com/ns.html?id=GTM-PR4QP6KH"
9+
height="0"
10+
width="0"
11+
style="display:none;visibility:hidden"></iframe>
12+
</noscript>
13+
<!-- End Google Tag Manager (noscript) -->
14+
15+
<Default />

0 commit comments

Comments
 (0)