Install with the CLI
Manual setup
1
Environment variable
.env.development and .env.production:2
Wire the tracker into gatsby-browser.js
gatsby-browser.js:Notes
gatsby-browser.jsonly runs in the browser, so it’s a safe place to instantiate the tracker at module scope.onClientEntryfires once, right after Gatsby boots — before any routes render — which means the tracker catches the very first page view.- The
GATSBY_prefix makes the variable available in bothprocess.env(server build time) andimport.meta.env(not used here).