Skip to content

Add Vercel Web Analytics to Astro project - #1

Open
vercel[bot] wants to merge 1 commit into
masterfrom
vercel/vercel-web-analytics-to-astro-v6yjqg
Open

Add Vercel Web Analytics to Astro project#1
vercel[bot] wants to merge 1 commit into
masterfrom
vercel/vercel-web-analytics-to-astro-v6yjqg

Conversation

@vercel

@vercel vercel Bot commented Feb 23, 2026

Copy link
Copy Markdown

Vercel Web Analytics Integration

Successfully installed and configured Vercel Web Analytics for the Astro project.

Changes Made

1. Package Installation

  • File: package.json
  • Action: Added @vercel/analytics@^1.6.1 to dependencies
  • Installed using pnpm to maintain consistency with the project's package manager

2. Base Layout Configuration

  • File: src/layouts/Layout.astro
  • Actions:
    • Added import statement: import Analytics from '@vercel/analytics/astro';
    • Placed the <Analytics /> component in the <head> section
    • Removed old incorrect analytics script that was attempting to use the inject method

3. Lock File Update

  • File: pnpm-lock.yaml
  • Action: Updated with new dependency information

Implementation Details

The Analytics component was added to src/layouts/Layout.astro, which is the base layout file that wraps all pages in the Astro site. This ensures analytics tracking is available on every page.

The component was placed in the <head> section as recommended by Vercel's documentation, which automatically includes route support for tracking page navigation.

Verification

  • ✅ Type checking passed: pnpm run check completed with 0 errors
  • ✅ Build successful: pnpm run build completed without errors
  • ✅ Package version: @vercel/analytics@1.6.1 (meets requirement of 1.4.0+)
  • ✅ Lock files updated correctly

Notes

  • The integration follows Vercel's official Astro documentation
  • Route tracking is automatically included with the Analytics component
  • No configuration file is needed; analytics will work automatically when deployed to Vercel
  • The component uses default export syntax as required by the package

View Project · Web Analytics

Created by XRYua (sxryua) with Vercel Agent

# Vercel Web Analytics Integration

Successfully installed and configured Vercel Web Analytics for the Astro project.

## Changes Made

### 1. Package Installation
- **File**: `package.json`
- **Action**: Added `@vercel/analytics@^1.6.1` to dependencies
- Installed using pnpm to maintain consistency with the project's package manager

### 2. Base Layout Configuration
- **File**: `src/layouts/Layout.astro`
- **Actions**:
  - Added import statement: `import Analytics from '@vercel/analytics/astro';`
  - Placed the `<Analytics />` component in the `<head>` section
  - Removed old incorrect analytics script that was attempting to use the inject method

### 3. Lock File Update
- **File**: `pnpm-lock.yaml`
- **Action**: Updated with new dependency information

## Implementation Details

The Analytics component was added to `src/layouts/Layout.astro`, which is the base layout file that wraps all pages in the Astro site. This ensures analytics tracking is available on every page.

The component was placed in the `<head>` section as recommended by Vercel's documentation, which automatically includes route support for tracking page navigation.

## Verification

- ✅ Type checking passed: `pnpm run check` completed with 0 errors
- ✅ Build successful: `pnpm run build` completed without errors
- ✅ Package version: @vercel/analytics@1.6.1 (meets requirement of 1.4.0+)
- ✅ Lock files updated correctly

## Notes

- The integration follows Vercel's official Astro documentation
- Route tracking is automatically included with the Analytics component
- No configuration file is needed; analytics will work automatically when deployed to Vercel
- The component uses default export syntax as required by the package

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

vercel Bot commented Feb 23, 2026

Copy link
Copy Markdown
Author

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

Project Deployment Actions Updated (UTC)
mizuki Ready Ready Preview, Comment Feb 23, 2026 2:43pm

@XRYua
XRYua marked this pull request as ready for review February 23, 2026 14:48
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