Nextjs-google-analytics

From version 2.3.0, Ncmaz has built-in script Nextjs-google-analytics, so please update the theme to the latest version, along with adding this environment variable to your project - NEXT_PUBLIC_GA_MEASUREMENT_ID

Usage:

Your Google Analytics measurement id is read from NEXT_PUBLIC_GA_MEASUREMENT_ID environment variable, so make sure it is set in your production environment:

If the variable is not set or is empty, nothing will be loaded, making it safe to work in development.

To load it and test it on development, add:

NEXT_PUBLIC_GA_MEASUREMENT_ID="G-XXXXXXXXXX"

to your .env.local file.

How to get a tracking ID - Google Analytics measurement id?

  1. Sign in with your Google account.

  2. Create a new property for your website and get a tracking ID of the form G-XXXXXXXXXX.

Last updated