- Added Terms of Service and Privacy Policy pages with contact info - Implemented Google Analytics with Consent Mode v2 for GDPR compliance - Created sitemap.xml and robots.txt for search engine optimization - Added dynamic meta tags, Open Graph, and structured data (JSON-LD) - Implemented GDPR consent banner with TCF 2.2 compatibility - Enhanced sidebar with category-colored hover states and proper active/inactive styling - Fixed all ESLint warnings for clean deployment - Added comprehensive SEO utilities and privacy-first analytics tracking Ready for production deployment with full legal compliance and SEO optimization.
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
import { useEffect } from 'react';
|
|
import { useLocation } from 'react-router-dom';
|
|
import { trackPageView, trackToolUsage, trackSearch, trackThemeChange } from '../utils/analytics';
|
|
|
|
// Custom hook for analytics tracking in React components
|
|
export const useAnalytics = () => {
|
|
const location = useLocation();
|
|
|
|
// Track page views on route changes
|
|
useEffect(() => {
|
|
const path = location.pathname;
|
|
let title = 'Dewe.Dev';
|
|
|
|
// Generate meaningful page titles
|
|
switch (path) {
|
|
case '/':
|
|
title = 'Dewe.Dev - Professional Developer Utilities';
|
|
break;
|
|
case '/object-editor':
|
|
title = 'Object Editor - Dewe.Dev';
|
|
break;
|
|
case '/table-editor':
|
|
title = 'Table Editor - Dewe.Dev';
|
|
break;
|
|
case '/url':
|
|
title = 'URL Encoder/Decoder - Dewe.Dev';
|
|
break;
|
|
case '/base64':
|
|
title = 'Base64 Encoder/Decoder - Dewe.Dev';
|
|
break;
|
|
case '/beautifier':
|
|
title = 'Code Beautifier/Minifier - Dewe.Dev';
|
|
break;
|
|
case '/diff':
|
|
title = 'Text Diff Checker - Dewe.Dev';
|
|
break;
|
|
case '/text-length':
|
|
title = 'Text Length Checker - Dewe.Dev';
|
|
break;
|
|
case '/privacy':
|
|
title = 'Privacy Policy - Dewe.Dev';
|
|
break;
|
|
case '/terms':
|
|
title = 'Terms of Service - Dewe.Dev';
|
|
break;
|
|
default:
|
|
title = `${path} - Dewe.Dev`;
|
|
}
|
|
|
|
// Track the page view
|
|
trackPageView(path, title);
|
|
}, [location]);
|
|
|
|
// Return tracking functions for components to use
|
|
return {
|
|
trackToolUsage,
|
|
trackSearch,
|
|
trackThemeChange,
|
|
};
|
|
};
|