Skip to content

Add Vercel Web Analytics to Next.js#1

Merged
richiemcilroy merged 1 commit into
mainfrom
vercel/vercel-web-analytics-to-nextjs-c05jak
Mar 6, 2026
Merged

Add Vercel Web Analytics to Next.js#1
richiemcilroy merged 1 commit into
mainfrom
vercel/vercel-web-analytics-to-nextjs-c05jak

Conversation

@vercel

@vercel vercel Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Vercel Web Analytics Installation

Successfully installed and configured Vercel Web Analytics for the Next.js App Router project.

Changes Made:

  1. Updated package.json (apps/web/package.json)

    • Added @vercel/analytics version ^1.4.1 to dependencies
    • This package provides the official Vercel Analytics integration for Next.js
  2. Updated Root Layout (apps/web/src/app/layout.tsx)

    • Imported Analytics component from @vercel/analytics/next
    • Added <Analytics /> component inside the <body> tag, after the {children} content
    • This follows the recommended pattern for App Router projects

Implementation Details:

The Analytics component was added to the root layout file, which ensures it's included on every page of the application. The component is placed after the main content ({children}) inside the body tag, which is the recommended location according to Vercel's documentation.

For App Router projects (using the app directory), this is the correct approach:

  • The component is imported from @vercel/analytics/next
  • It's placed in the root layout at src/app/layout.tsx
  • No configuration is needed - analytics will automatically track page views

Next Steps:

To complete the setup:

  1. Run bun install (or your package manager) from the root directory to install dependencies and update the bun.lock file
  2. Deploy the application to Vercel to enable analytics tracking
  3. Analytics data will be available in the Vercel dashboard once deployed

Notes:

  • The implementation preserves all existing code structure and styling
  • No breaking changes were introduced
  • The Analytics component is lightweight and won't impact page performance
  • Analytics will only be active when deployed to Vercel (no tracking in development mode by default)

View Project · Web Analytics

Created by richiemcilroy with Vercel Agent

## Vercel Web Analytics Installation

Successfully installed and configured Vercel Web Analytics for the Next.js App Router project.

### Changes Made:

1. **Updated package.json** (`apps/web/package.json`)
   - Added `@vercel/analytics` version `^1.4.1` to dependencies
   - This package provides the official Vercel Analytics integration for Next.js

2. **Updated Root Layout** (`apps/web/src/app/layout.tsx`)
   - Imported `Analytics` component from `@vercel/analytics/next`
   - Added `<Analytics />` component inside the `<body>` tag, after the `{children}` content
   - This follows the recommended pattern for App Router projects

### Implementation Details:

The Analytics component was added to the root layout file, which ensures it's included on every page of the application. The component is placed after the main content (`{children}`) inside the body tag, which is the recommended location according to Vercel's documentation.

For App Router projects (using the `app` directory), this is the correct approach:
- The component is imported from `@vercel/analytics/next`
- It's placed in the root layout at `src/app/layout.tsx`
- No configuration is needed - analytics will automatically track page views

### Next Steps:

To complete the setup:
1. Run `bun install` (or your package manager) from the root directory to install dependencies and update the bun.lock file
2. Deploy the application to Vercel to enable analytics tracking
3. Analytics data will be available in the Vercel dashboard once deployed

### Notes:

- The implementation preserves all existing code structure and styling
- No breaking changes were introduced
- The Analytics component is lightweight and won't impact page performance
- Analytics will only be active when deployed to Vercel (no tracking in development mode by default)

Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandchest-web Ready Ready Preview, Comment Mar 6, 2026 5:30pm

@richiemcilroy richiemcilroy marked this pull request as ready for review March 6, 2026 17:32
@richiemcilroy richiemcilroy merged commit e3fd3fa into main Mar 6, 2026
3 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant