Cara menambahkan Google Analytic di Next JS

Kali ini saya akan berbagi pengalaman menambahkan Google Analytic ke dalam Project Next JS

Pertama install terlebih dahulu Library goolgle analytic dengan menggunakan npm atau yarn

npm install --save nextjs-google-analytics

emudian tambahkan variable uang berisi ID Google analytic ke dalam file .local.env

NEXT_PUBLIC_GA_MEASUREMENT_ID="G-XXXXXXXXX"

Kemudian tambahan beberapa baris kodingan kedalam file pages/_app.tsx

return(
<>
<GoogleAnalytics />
<Component {...pageProps} />
</>
)

--

--

Fullstack Developer at Nuliscv.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store