Skip to content

Commit

Permalink
feat: added google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenbupe committed Aug 17, 2024
1 parent dae3a3e commit 9d9f57e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface Props {
}
const { title } = Astro.props;
const analyticsId = import.meta.env.GOOGLE_ANALYTICS_ID;
---

<!doctype html>
Expand All @@ -19,6 +21,18 @@ const { title } = Astro.props;
<meta name="description" content={siteDescription} />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="sitemap" href="/sitemap-index.xml" />
{!!analyticsId && (
<>
<script is:inline async src={`https://www.googletagmanager.com/gtag/js?id=${analyticsId}`} />
<script is:inline define:vars={{analyticsId}}>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', `${analyticsId}`);
</script>
</>
)}

<link
rel="apple-touch-icon"
Expand Down
1 change: 0 additions & 1 deletion src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Spotlight from "../components/Spotlight.astro";
---

<Layout>
Expand Down
1 change: 0 additions & 1 deletion src/pages/500.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Spotlight from "../components/Spotlight.astro";
---

<Layout>
Expand Down
1 change: 0 additions & 1 deletion src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getCollection, type CollectionEntry } from "astro:content";
import Layout from "../../layouts/Layout.astro";
import { formatDate } from "../../lib/utils";
import { Image } from "astro:assets";
import Spotlight from "../../components/Spotlight.astro";
export async function getStaticPaths() {
const posts = await getCollection("blog");
Expand Down
1 change: 0 additions & 1 deletion src/pages/blog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Layout from "../../layouts/Layout.astro";
import Section from "../../components/Section.astro";
import BlogCard from "../../components/BlogCard.astro";
import { Particles } from "../../components/Particles";
import Spotlight from "../../components/Spotlight.astro";
const posts = await getPosts();
const featuredPosts = await getFeaturedPosts();
Expand Down
1 change: 0 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import Layout from "../layouts/Layout.astro";
import Spotlight from "../components/Spotlight.astro";
import Hero from "../sections/Hero.astro";
import About from "../sections/About.astro";
import Jobs from "../sections/Jobs.astro";
Expand Down

0 comments on commit 9d9f57e

Please sign in to comment.