Skip to content

Install Vercel Web Analytics#123

Draft
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/install-vercel-web-analytics-okdd0m
Draft

Install Vercel Web Analytics#123
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/install-vercel-web-analytics-okdd0m

Conversation

@vercel

@vercel vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

Vercel Web Analytics Implementation

Successfully installed and configured Vercel Web Analytics for the TanStack Start application.

Changes Made

1. Package Installation

  • File Modified: apps/web/package.json
  • Action: Added @vercel/analytics version ^2.0.1 as a dependency
  • Method: Used pnpm add @vercel/analytics in the apps/web directory

2. Analytics Component Integration

  • File Modified: apps/web/src/routes/__root.tsx
  • Actions:
    • Added import: import { Analytics } from "@vercel/analytics/react";
    • Added <Analytics /> component in the body section, after other components like <AuthRequirePopup /> and <LoginResultModal />

3. Lock File Update

  • File Modified: pnpm-lock.yaml
  • Action: Updated automatically when installing the package to ensure dependency consistency

Implementation Details

According to the official Vercel Analytics documentation (fetched from https://vercel.com/docs/analytics/quickstart), for React applications using frameworks like TanStack Start, the correct approach is to:

  1. Import from @vercel/analytics/react
  2. Add the <Analytics /> component to the root layout

This implementation follows the framework-specific instructions for React applications. The Analytics component was placed in the RootDocument shell component within the <body> tag, alongside other application-level components, ensuring it tracks all page views across the application.

Verification

  • Linting: The modified __root.tsx file passes all Biome checks with no errors
  • Tests: All 418 existing passing tests continue to pass
  • ⚠️ Build: There are pre-existing build issues in the project related to react-aria-components module resolution that are unrelated to the Analytics changes
  • Lock File: The pnpm-lock.yaml file has been properly updated with the new dependency

Next Steps for the User

To complete the Vercel Web Analytics setup:

  1. Enable Analytics in Vercel Dashboard:

    • Navigate to your project in the Vercel dashboard
    • Go to the Analytics section
    • Click "Enable" to activate Web Analytics
    • This will add routes at /_vercel/insights/* after your next deployment
  2. Deploy the Application:

    • Deploy this branch to Vercel using vercel deploy
    • The Analytics tracking will automatically start collecting data
  3. Verify Installation:

    • After deployment, visit your site
    • Open browser DevTools → Network tab
    • Look for a Fetch/XHR request to /_vercel/insights/view
    • This confirms Analytics is working correctly
  4. View Analytics Data:

    • Return to the Vercel dashboard
    • Navigate to your project's Analytics section
    • View real-time and historical analytics data

Notes

  • The Analytics component is lightweight and adds minimal overhead to the application
  • It automatically tracks page views and web vitals
  • No additional configuration is required for basic analytics tracking
  • The implementation follows the official Vercel documentation guidelines

View Project · Web Analytics

Created by zimdugo (zimdugo) with Vercel Agent

# Vercel Web Analytics Implementation

Successfully installed and configured Vercel Web Analytics for the TanStack Start application.

## Changes Made

### 1. Package Installation
- **File Modified**: `apps/web/package.json`
- **Action**: Added `@vercel/analytics` version `^2.0.1` as a dependency
- **Method**: Used `pnpm add @vercel/analytics` in the apps/web directory

### 2. Analytics Component Integration
- **File Modified**: `apps/web/src/routes/__root.tsx`
- **Actions**:
  - Added import: `import { Analytics } from "@vercel/analytics/react";`
  - Added `<Analytics />` component in the body section, after other components like `<AuthRequirePopup />` and `<LoginResultModal />`
  
### 3. Lock File Update
- **File Modified**: `pnpm-lock.yaml`
- **Action**: Updated automatically when installing the package to ensure dependency consistency

## Implementation Details

According to the official Vercel Analytics documentation (fetched from https://vercel.com/docs/analytics/quickstart), for React applications using frameworks like TanStack Start, the correct approach is to:

1. Import from `@vercel/analytics/react`
2. Add the `<Analytics />` component to the root layout

This implementation follows the framework-specific instructions for React applications. The Analytics component was placed in the `RootDocument` shell component within the `<body>` tag, alongside other application-level components, ensuring it tracks all page views across the application.

## Verification

- ✅ **Linting**: The modified `__root.tsx` file passes all Biome checks with no errors
- ✅ **Tests**: All 418 existing passing tests continue to pass
- ⚠️ **Build**: There are pre-existing build issues in the project related to `react-aria-components` module resolution that are unrelated to the Analytics changes
- ✅ **Lock File**: The pnpm-lock.yaml file has been properly updated with the new dependency

## Next Steps for the User

To complete the Vercel Web Analytics setup:

1. **Enable Analytics in Vercel Dashboard**:
   - Navigate to your project in the Vercel dashboard
   - Go to the Analytics section
   - Click "Enable" to activate Web Analytics
   - This will add routes at `/_vercel/insights/*` after your next deployment

2. **Deploy the Application**:
   - Deploy this branch to Vercel using `vercel deploy`
   - The Analytics tracking will automatically start collecting data

3. **Verify Installation**:
   - After deployment, visit your site
   - Open browser DevTools → Network tab
   - Look for a Fetch/XHR request to `/_vercel/insights/view`
   - This confirms Analytics is working correctly

4. **View Analytics Data**:
   - Return to the Vercel dashboard
   - Navigate to your project's Analytics section
   - View real-time and historical analytics data

## Notes

- The Analytics component is lightweight and adds minimal overhead to the application
- It automatically tracks page views and web vitals
- No additional configuration is required for basic analytics tracking
- The implementation follows the official Vercel documentation guidelines

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

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown
Author

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

Project Deployment Actions Updated (UTC)
zimdugo-admin Ready Ready Preview, Comment Jul 15, 2026 7:57am
zimdugo-storybook Ready Ready Preview, Comment Jul 15, 2026 7:57am
zimdugo-web Ready Ready Preview, Comment Jul 15, 2026 7:57am

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.

0 participants