Skip to content

Files

Latest commit

12fe7c4 · Jun 3, 2025

History

History
52 lines (34 loc) · 1.86 KB

analytics.md

File metadata and controls

52 lines (34 loc) · 1.86 KB

Analytics

Overview

This project uses @next/third-parties for integrating Google Analytics and Google Tag Manager in a Next.js optimized way.

Implemented Services

Google Analytics

import { GoogleAnalytics } from '@next/third-parties/google'

// Usage in layout.tsx
{env.NEXT_PUBLIC_GA_ID && isProduction && <GoogleAnalytics gaId={env.NEXT_PUBLIC_GA_ID} />}

Google Tag Manager

import { GoogleTagManager } from '@next/third-parties/google'

// Usage in layout.tsx
{env.NEXT_PUBLIC_GTM_ID && isProduction && <GoogleTagManager gtmId={env.NEXT_PUBLIC_GTM_ID} />}

Configuration

Environment Variables

Required environment variables for analytics setup (optional features):

Variable Purpose Required
NEXT_PUBLIC_GA_ID Google Analytics Measurement ID No
NEXT_PUBLIC_GTM_ID Google Tag Manager Container ID No

For detailed environment variable setup, refer to Environment Variables Documentation.

Related Resources