Add Vercel Web Analytics to Astro project - #1
Open
vercel[bot] wants to merge 1 commit into
Open
Conversation
# 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>
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
XRYua
marked this pull request as ready for review
February 23, 2026 14:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vercel Web Analytics Integration
Successfully installed and configured Vercel Web Analytics for the Astro project.
Changes Made
1. Package Installation
package.json@vercel/analytics@^1.6.1to dependencies2. Base Layout Configuration
src/layouts/Layout.astroimport Analytics from '@vercel/analytics/astro';<Analytics />component in the<head>section3. Lock File Update
pnpm-lock.yamlImplementation 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
pnpm run checkcompleted with 0 errorspnpm run buildcompleted without errorsNotes
View Project · Web Analytics
Created by XRYua (sxryua) with Vercel Agent