From 65a701167758b07c76ff82793b5b0a84ebde00ee Mon Sep 17 00:00:00 2001 From: hhff Date: Tue, 27 Jan 2026 11:57:07 -0800 Subject: [PATCH] Add GA --- www/app/layout.tsx | 13 +++++++++++++ www/app/page.tsx | 20 ++++++++++++++++++++ www/components/EmailGateModal.tsx | 11 ++++++++++- www/components/Navigation.tsx | 16 ++++++++++++++++ www/components/SubscribeForm.tsx | 10 +++++++++- www/types/gtag.d.ts | 12 ++++++++++++ 6 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 www/types/gtag.d.ts diff --git a/www/app/layout.tsx b/www/app/layout.tsx index 752d1d6..0fab2c9 100644 --- a/www/app/layout.tsx +++ b/www/app/layout.tsx @@ -1,4 +1,5 @@ import type { Metadata } from "next"; +import Script from "next/script"; import "./globals.css"; import EmailGateWrapper from "@/components/EmailGateWrapper"; @@ -38,6 +39,18 @@ export default function RootLayout({ return ( + {children} diff --git a/www/app/page.tsx b/www/app/page.tsx index 0183ff1..bdec317 100644 --- a/www/app/page.tsx +++ b/www/app/page.tsx @@ -1,3 +1,5 @@ +'use client'; + import SectionHeader from "@/components/SectionHeader"; import PullQuote from "@/components/PullQuote"; import LeafIcon from "@/components/LeafIcon"; @@ -180,6 +182,15 @@ export default function Home() { { + if (typeof window !== 'undefined' && window.gtag) { + window.gtag('event', 'work_with_us_click', { + event_category: 'engagement', + event_label: 'top_right_button', + value: 1 + }); + } + }} className="block p-4 rounded bg-fi-green-200 hover:bg-fi-green-300 transition-colors" >

Work with Us

@@ -919,6 +930,15 @@ export default function Home() {
{ + if (typeof window !== 'undefined' && window.gtag) { + window.gtag('event', 'email_click', { + event_category: 'engagement', + event_label: 'partner_email', + value: 1 + }); + } + }} className="no-underline hover:underline" > partner@intelligence.family diff --git a/www/components/EmailGateModal.tsx b/www/components/EmailGateModal.tsx index 4c0dcec..b9936ff 100644 --- a/www/components/EmailGateModal.tsx +++ b/www/components/EmailGateModal.tsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; -type SubscribeStatus = 'idle' | 'loading' | 'subscribed' | 'error'; +type SubscribeStatus = 'idle' | 'loading' | 'subscribed' | 'already_subscribed' | 'error'; interface EmailGateModalProps { onSuccess: () => void; @@ -51,6 +51,15 @@ export default function EmailGateModal({ onSuccess }: EmailGateModalProps) { setStatus('subscribed'); setMessage(data.message); + // Send Google Analytics event + if (typeof window !== 'undefined' && window.gtag) { + window.gtag('event', 'email_subscribe', { + event_category: 'engagement', + event_label: 'email_gate', + value: 1 + }); + } + // Start fade out animation setTimeout(() => { setIsFadingOut(true); diff --git a/www/components/Navigation.tsx b/www/components/Navigation.tsx index 372eece..e2916ea 100644 --- a/www/components/Navigation.tsx +++ b/www/components/Navigation.tsx @@ -121,6 +121,14 @@ export default function Navigation() { onClick={(e) => { e.preventDefault(); document.getElementById(id)?.scrollIntoView({ behavior: "smooth" }); + // Track "Work with Us" clicks in sidebar + if (id === 'work-with-us' && typeof window !== 'undefined' && window.gtag) { + window.gtag('event', 'work_with_us_click', { + event_category: 'engagement', + event_label: 'sidebar_menu', + value: 1 + }); + } }} className={`flex items-center whitespace-nowrap transition-colors duration-200 ${ isActive @@ -166,6 +174,14 @@ function MobileNavContent({ activeSection }: { activeSection: string }) { onClick={(e) => { e.preventDefault(); document.getElementById(id)?.scrollIntoView({ behavior: "smooth" }); + // Track "Work with Us" clicks in mobile nav + if (id === 'work-with-us' && typeof window !== 'undefined' && window.gtag) { + window.gtag('event', 'work_with_us_click', { + event_category: 'engagement', + event_label: 'mobile_menu', + value: 1 + }); + } }} className={`flex flex-col items-center text-center transition-colors ${ isActive diff --git a/www/components/SubscribeForm.tsx b/www/components/SubscribeForm.tsx index e9a3f5d..21961b8 100644 --- a/www/components/SubscribeForm.tsx +++ b/www/components/SubscribeForm.tsx @@ -30,8 +30,16 @@ export default function SubscribeForm() { setStatus(data.status); setMessage(data.message); - if (data.status === 'subscribed') { + if (data.status === 'subscribed' || data.status === 'already_subscribed') { setEmail(''); + // Send Google Analytics event + if (typeof window !== 'undefined' && window.gtag) { + window.gtag('event', 'email_subscribe', { + event_category: 'engagement', + event_label: 'subscribe_form', + value: 1 + }); + } } } catch (error) { console.error('Subscribe error:', error); diff --git a/www/types/gtag.d.ts b/www/types/gtag.d.ts new file mode 100644 index 0000000..77701b2 --- /dev/null +++ b/www/types/gtag.d.ts @@ -0,0 +1,12 @@ +declare global { + interface Window { + gtag?: ( + command: 'config' | 'event' | 'js' | 'set', + targetId: string | Date | Record, + config?: Record + ) => void; + dataLayer?: any[]; + } +} + +export {};