google adsense

This commit is contained in:
Sammy Shear 2024-07-26 11:43:33 -04:00
parent a729386a92
commit 2b2745d669
Signed by: sammyshear
GPG Key ID: 69B1EDA35F4F4C09
4 changed files with 81 additions and 79 deletions

View File

@ -1,23 +1,25 @@
--- ---
type Props = { measurementId: string } type Props = { measurementId: string };
const props = Astro.props as Props const props = Astro.props as Props;
const measurementId = props.measurementId const measurementId = props.measurementId;
--- ---
<script <script
type='text/partytown' type="text/partytown"
src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`}></script> src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`}
></script>
<script <script
type='text/partytown' type="text/partytown"
data-ga-measurement-id={measurementId} data-ga-measurement-id={measurementId}
id='ga-init' id="ga-init"
> >
const measurementId = document const measurementId = document
.getElementById('ga-init') .getElementById("ga-init")
.getAttribute('data-ga-measurement-id') .getAttribute("data-ga-measurement-id");
window.dataLayer = window.dataLayer || [] window.dataLayer = window.dataLayer || [];
function gtag() { function gtag() {
dataLayer.push(arguments) // eslint-disable-line dataLayer.push(arguments); // eslint-disable-line
} }
gtag('js', new Date()) gtag("js", new Date());
gtag('config', measurementId) gtag("config", measurementId);
</script> </script>

View File

@ -25,15 +25,13 @@ const {
<meta name="author" content={author} /> <meta name="author" content={author} />
<meta name="description" content={description} /> <meta name="description" content={description} />
<link rel="sitemap" href="/sitemap-index.xml" /> <link rel="sitemap" href="/sitemap-index.xml" />
<meta name="google-adsense-account" content="ca-pub-2655673927481085" />
<title>{title}</title> <title>{title}</title>
</head> </head>
<body <body
class="flex flex-col place-items-center bg-ctp-base ctp-latte text-ctp-text dark:ctp-mocha" class="flex flex-col place-items-center bg-ctp-base ctp-latte text-ctp-text dark:ctp-mocha"
> >
<slot /> <slot />
</body>
</html>
<style is:global> <style is:global>
html.dark .astro-code, html.dark .astro-code,
html.dark .astro-code span { html.dark .astro-code span {
@ -67,3 +65,5 @@ const {
} }
window.localStorage.setItem("theme", theme); window.localStorage.setItem("theme", theme);
</script> </script>
</body>
</html>