feat(analytics): enhance Google Analytics with privacy compliance and comprehensive tracking
- Add automatic route change tracking for SPA navigation - Implement Cookie consent banner for GDPR compliance - Add performance tracking (LCP, FID, CLS Web Vitals) - Add outbound link click tracking - Integrate contact form submission tracking with conversion events - Add CTA button click tracking in hero section - Integrate error tracking in ErrorBoundary component - Extend analytics utility library with 15+ tracking functions - Configure IP anonymization and privacy settings - Remove unused test files and deployment scripts - Update case studies to include only specified cases - Fix mobile navigation active state issues - Fix lint errors in test files and components BREAKING CHANGE: Google Analytics now requires user consent before tracking
This commit is contained in:
@@ -10,6 +10,12 @@ import { Button } from '@/components/ui/button';
|
||||
import { COMPANY_INFO, NAVIGATION, type NavigationItem } from '@/lib/constants';
|
||||
import { useFocusTrap } from '@/hooks/use-focus-trap';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__isProgrammaticScroll?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
function HeaderContent() {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isScrolled, setIsScrolled] = useState(false);
|
||||
@@ -34,9 +40,9 @@ function HeaderContent() {
|
||||
const handleScroll = () => {
|
||||
setIsScrolled(window.scrollY > 20);
|
||||
|
||||
if (pathname === '/' && !isScrollingRef.current) {
|
||||
if (pathname === '/' && !isScrollingRef.current && !window.__isProgrammaticScroll) {
|
||||
const scrollPosition = window.scrollY + 100;
|
||||
const sections = ['home', 'services', 'solutions', 'products', 'cases', 'about', 'news'];
|
||||
const sections = ['home', 'services', 'solutions', 'products', 'cases', 'about', 'team', 'news'];
|
||||
|
||||
for (const sectionId of sections) {
|
||||
const element = document.getElementById(sectionId);
|
||||
@@ -158,6 +164,7 @@ function HeaderContent() {
|
||||
<StaticLink
|
||||
href="/"
|
||||
className="flex items-center group"
|
||||
aria-label="返回首页"
|
||||
>
|
||||
<Image
|
||||
src="/logo.svg"
|
||||
@@ -165,6 +172,7 @@ function HeaderContent() {
|
||||
width={32}
|
||||
height={32}
|
||||
className="h-8 w-auto transition-transform duration-200 group-hover:scale-105"
|
||||
loading="eager"
|
||||
priority
|
||||
/>
|
||||
</StaticLink>
|
||||
|
||||
Reference in New Issue
Block a user