Skip to content

chore : read GA_MEASUREMENT_ID from NEXT_PUBLIC_GA_ID environment variable - #5

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

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

Conversation

@tmdeveloper007

Copy link
Copy Markdown

Closes (upstream issues disabled — no issue created).

Summary of What Has Been Done:
Updated lib/gtag.js to read the Google Analytics Measurement ID from the NEXT_PUBLIC_GA_ID environment variable instead of using a hardcoded string. The NEXT_PUBLIC_GA_ID variable is already documented in EnvExample.txt but was never wired into the code. The existing hardcoded value is kept as a fallback so local development continues to work without any env var set.

Changes Made:

  • lib/gtag.js: read GA_MEASUREMENT_ID from process.env.NEXT_PUBLIC_GA_ID with fallback to the previous hardcoded value

Impact it Made:

  • Allows different GA measurement IDs per deployment environment (dev/staging/prod)
  • Reduces accidental leakage of production analytics data in non-production environments
  • No functional change when env var is not set (backward compatible)

Note: Please assign this PR to the tmdeveloper007 account.

NEXT_PUBLIC_GA_ID is already listed in EnvExample.txt but the actual
gtag.js was using a hardcoded value. Read from env first with the
existing hardcoded value as fallback for backward compatibility.
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