export const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID || ''; declare global { interface Window { gtag: (command: string, targetId: string, config?: Record) => void; } } export const pageview = (url: string) => { if (typeof window !== 'undefined' && window.gtag && GA_MEASUREMENT_ID) { window.gtag('config', GA_MEASUREMENT_ID, { page_path: url, }); } }; export const event = (action: string, category: string, label?: string, value?: number) => { if (typeof window !== 'undefined' && window.gtag && GA_MEASUREMENT_ID) { window.gtag('event', action, { event_category: category, event_label: label, value: value, }); } }; export const trackContactForm = (_formData: Record) => { event('submit', 'contact_form', 'contact_form_submission'); }; export const trackButtonClick = (buttonName: string, location: string) => { event('click', 'button', `${location}_${buttonName}`); }; export const trackPageView = (pageTitle: string, _pagePath: string) => { event('page_view', 'navigation', pageTitle); };