Skip to content

Commit

Permalink
Adding Google Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
petrovicz committed Apr 9, 2024
1 parent 2a184cf commit c6b7c6f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
7 changes: 4 additions & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { defineConfig } from 'astro/config';

import tailwind from "@astrojs/tailwind";

import partytown from "@astrojs/partytown";

// https://astro.build/config
export default defineConfig({
integrations: [tailwind()],
site: 'https://astro-photoswipe.petrovicz.com'
integrations: [tailwind(), partytown()],
site: 'https://astro-photoswipe.petrovicz.com'
});
29 changes: 29 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@astrojs/check": "^0.5.10",
"@astrojs/partytown": "^2.0.4",
"@astrojs/tailwind": "^5.1.0",
"astro": "^4.5.15",
"photoswipe": "^5.4.3",
Expand Down
18 changes: 18 additions & 0 deletions src/components/GoogleAnalytics.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
---

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

gtag("config", "G-KVQ6PK5KQK");
</script>
7 changes: 6 additions & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
---
import GoogleAnalytics from "../components/GoogleAnalytics.astro";
import Navbar from "../components/Navbar.astro";
---

<html lang="en">
<head>
<GoogleAnalytics />
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<meta name="description" content="Demonstrating PhotoSwipe inside Astro, with automatic image optimizations." />
<meta
name="description"
content="Demonstrating PhotoSwipe inside Astro, with automatic image optimizations."
/>
<title>Astro + PhotoSwipe</title>
</head>
<body>
Expand Down

0 comments on commit c6b7c6f

Please sign in to comment.