Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Analytics #5

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { defineConfig } from "astro/config";
import tailwind from "@astrojs/tailwind";

import critters from "astro-critters";

import partytown from "@astrojs/partytown";

// https://astro.build/config
export default defineConfig({
integrations: [tailwind(), critters()],
integrations: [
tailwind(),
partytown({
config: {
forward: ["dataLayer.push"],
},
}),
critters(),
],
});
4 changes: 3 additions & 1 deletion lighthouserc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ module.exports = {
// see: https://github.com/GoogleChrome/lighthouse/issues/14784
"bf-cache": "off",
// don't think it's possible to properly evaluate csp either
"csp-xss": ["off"],
"csp-xss": "off",
// google analytics has unused js, since we don't own it there's nothing we can do
"unused-javascript": "warn",
},
},
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"format": "prettier --write . --plugin=prettier-plugin-tailwindcss --plugin=prettier-plugin-astro"
},
"dependencies": {
"@astrojs/partytown": "^2.0.0",
"@astrojs/tailwind": "^5.0.0",
"@fontsource-variable/inter": "^5.0.8",
"@types/canvas-confetti": "^1.6.0",
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/layouts/main.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import "@fontsource-variable/inter";

<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script
type="text/partytown"
src="https://www.googletagmanager.com/gtag/js?id=G-LZ04W4C9XR"></script>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());

gtag("config", "G-LZ04W4C9XR");
</script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
Expand Down