
How can you add Google Analytics in Nextjs 13?Learn in 2 minutes

Table Of Contents
Create a Google Analytics account by visiting the Google Analytics website and following the signup process.
Get your Tracking ID
You'll receive a tracking ID after creating your account. It looks like "UA-XXXXXXXXX-X". Keep this ID handy, as you'll need it to integrate Google Analytics with your Next.js project.
Implement with NEXTJS
Import your Script into your _app.tsx or _app.jsx while you want to add analytics globally
import Script from "next/script";
<Script async strategy="afterInteractive" src="https://www.googletagmanager.com/gtag/js?id=UA-1196-1" />
Verify Tracking
Once you've added the tracking code, you can verify its implementation by visiting your website and checking your Google Analytics dashboard's "Realtime" section. It may take some time for data to start showing up.
That's it! You've successfully added Google Analytics to your Next.js 13 project. You'll now be able to track user interactions, page views, and more to gain insights into how your website is being used.