Skip to content

Commit

Permalink
adding GTM components
Browse files Browse the repository at this point in the history
  • Loading branch information
rambleraptor committed Oct 10, 2024
1 parent e4d1455 commit 28dd65b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
18 changes: 5 additions & 13 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,13 @@ export default defineConfig({
social: {
github: config.urls.repo,
},
sidebar: sidebar
sidebar: sidebar,
components: {
'Head': './src/components/overrides/Head.astro',
'PageFrame': './src/components/overrides/PageFrame.astro',
}
}),
tailwind({
applyBaseStyles: false,
})],
vite: {
plugins: [
VitePluginRadar({
analytics: {
id: config.site.ga_tag
},
gtm: {
id: config.site.ga_tag
},
}),
],
}
});
19 changes: 19 additions & 0 deletions src/components/overrides/Head.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import Default from "@astrojs/starlight/components/Head.astro";
---

<!-- Google Tag Manager -->
<script is:inline>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != "dataLayer" ? "&l=" + l : "";
j.async = true;
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, "script", "dataLayer", "GTM-NSXMVSDN");
</script>
<!-- End Google Tag Manager -->
<Default {...Astro.props}><slot /></Default>
14 changes: 14 additions & 0 deletions src/components/overrides/PageFrame.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
import Default from "@astrojs/starlight/components/PageFrame.astro";
---

<!-- Google Tag Manager (noscript) -->
<noscript
><iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-NSXMVSDN"
height="0"
width="0"
style="display:none;visibility:hidden"></iframe></noscript
>
<!-- End Google Tag Manager (noscript) -->
<Default {...Astro.props}><slot /></Default>

0 comments on commit 28dd65b

Please sign in to comment.