Skip to content

fix : read GA_MEASUREMENT_ID from NEXT_PUBLIC_GA_ID environment variable - #20

Open
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:#gtag-env-var-fix
Open

fix : read GA_MEASUREMENT_ID from NEXT_PUBLIC_GA_ID environment variable#20
tmdeveloper007 wants to merge 1 commit into
syedahmedkhaderi:mainfrom
tmdeveloper007:#gtag-env-var-fix

Conversation

@tmdeveloper007

Copy link
Copy Markdown

Summary of What Has Been Done:
Changed lib/gtag.js to read the Google Analytics measurement ID from the NEXT_PUBLIC_GA_ID environment variable instead of using a hardcoded string. EnvExample.txt already documents NEXT_PUBLIC_GA_ID as the correct variable to set.

Changes Made:

  • lib/gtag.js: changed GA_MEASUREMENT_ID from hardcoded 'G-N8XGEXJXEM' to process.env.NEXT_PUBLIC_GA_ID || 'G-N8XGEXJXEM'

Impact it Made:

  • Follows the 12-factor app principle of storing config in environment
  • Allows different GA IDs per deployment environment
  • Hardcoded fallback preserves existing behavior if the env var is not set
  • Verified: npm run build passes

Read the Google Analytics measurement ID from NEXT_PUBLIC_GA_ID
env var instead of using a hardcoded string. EnvExample.txt
already documents this variable. The hardcoded fallback preserves
the existing ID for environments where the variable is not set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant