Google Analytics

Setup

Complete these steps to add Google Analytics to your website.

1

Step 1

On the Google Analytics dashboard, pick your project, click on the Analytics tab, and then click Enable.

2

Step 2

Add the @next/third-parties package to your project using your preferred package manager.

  npm i @next/third-parties@latest
3

Step 3

Add this component to the root layout. It wraps around the tracking script to integrate smoothly with Next.js.

app/layout.tsx
import { GoogleAnalytics } from '@next/third-parties/google';

...
<body>
  {children}
  <GoogleAnalytics gaId="G-XYZ" />
</body>
...
4

Step 4

Deploy your app to Vercel to see the analytics in the dashboard.

Events

Here’s how to track form button submit events with custom event goals in Plausible: Custom Event Goals Documentation.

After Adding the Script

After adding the script, you can view the analytics in the dashboard. You can see the number of visitors, page views, and referrers. You can also see the number of visitors per country and the most visited pages.

If you need more analytics documentations or have any questions, feel free to ask in the Discord community or contact us here.