diff --git a/src/app/layout.js b/src/app/layout.js
index 656033e6..b0742d5c 100644
--- a/src/app/layout.js
+++ b/src/app/layout.js
@@ -7,21 +7,25 @@ import "./styles/text-link.scss";
import { Suspense } from "react";
import meta from "@/components/Meta/Meta";
import LoadingScreen from "@/components/Loading/LoadingScreen";
+import Plausible from "@/components/Analytics/Plausible";
export const metadata = meta();
export default function RootLayout({ children }) {
- return (
-
-
-
-
-
- }>{children}
-
-
-
-
-
- );
+ return (
+
+
+
+
+
+
+
+
+ }>{children}
+
+
+
+
+
+ );
}
diff --git a/src/components/Analytics/Plausible.js b/src/components/Analytics/Plausible.js
new file mode 100644
index 00000000..20eae4b1
--- /dev/null
+++ b/src/components/Analytics/Plausible.js
@@ -0,0 +1,23 @@
+"use client";
+
+import Script from "next/script";
+
+export default function Plausible() {
+ return (
+ <>
+
+
+ >
+ );
+}
diff --git a/src/components/Heroes/PrimaryHero.js b/src/components/Heroes/PrimaryHero.js
index d5565ebf..4c305216 100644
--- a/src/components/Heroes/PrimaryHero.js
+++ b/src/components/Heroes/PrimaryHero.js
@@ -3,79 +3,72 @@ import { useEffect, useRef } from "react";
import Container from "@/components/Container/Container";
import BorderButton from "@/macros/Buttons/BorderButton";
import { Display, Body } from "@/macros/Copy";
+import { usePlausible } from "@/hooks/usePlausible";
const PrimaryHero = ({ headline, subheadline, buttons, videos }) => {
- const videoRef = useRef(null);
- useEffect(() => {
- if (videoRef.current) {
- videoRef.current.play().catch((error) => {
- // Handle error if playback fails
- console.error("Video failed to play:", error);
- });
- }
- }, []);
+ const videoRef = useRef(null);
+ const trackEvent = usePlausible();
- return (
-
- {videos && (
-
- )}
-
-
-
- {headline}
-
-
- {subheadline}
-
-
- {buttons.map((button, index) => (
-
- {button.text}
-
- ))}
-
-
-
-
- );
+ useEffect(() => {
+ if (videoRef.current) {
+ videoRef.current.play().catch((error) => {
+ // Handle error if playback fails
+ console.error("Video failed to play:", error);
+ });
+ }
+ }, []);
+
+ const handleButtonClick = (buttonText, url) => {
+ trackEvent("hero_button_click", {
+ button_text: buttonText,
+ destination: url,
+ });
+ };
+
+ return (
+
+ {videos && (
+
+ )}
+
+
+
+ {headline}
+
+
+ {subheadline}
+
+
+ {buttons.map((button, index) => (
+ handleButtonClick(button.text, button.url)}
+ href={button.url}
+ className='md:inline-flex'
+ >
+ {button.text}
+
+ ))}
+
+
+
+
+ );
};
export default PrimaryHero;
diff --git a/src/hooks/usePlausible.js b/src/hooks/usePlausible.js
new file mode 100644
index 00000000..42bdec65
--- /dev/null
+++ b/src/hooks/usePlausible.js
@@ -0,0 +1,11 @@
+"use client";
+
+export function usePlausible() {
+ const trackEvent = (eventName, props = {}) => {
+ if (typeof window !== "undefined" && window.plausible) {
+ window.plausible(eventName, { props });
+ }
+ };
+
+ return trackEvent;
+}