feat: Install and Configure Vercel Web Analytics#20
Merged
Conversation
## Vercel Web Analytics Installation Complete
Successfully installed and configured Vercel Web Analytics for this Astro project.
### Changes Made:
1. **Installed @vercel/analytics package (v2.0.1)**
- Added `@vercel/analytics` as a dependency in package.json
- Used `npm install --legacy-peer-deps` to resolve peer dependency conflicts with Vite versions
- Updated package-lock.json accordingly
2. **Configured Analytics in Head Component**
- Modified `src/components/Head.astro` to import and inject Vercel Analytics
- Added `import { inject } from "@vercel/analytics";` at the top
- Called `inject()` in the component frontmatter to initialize analytics
- This ensures analytics tracking is loaded on all pages since Head.astro is used as a custom head component throughout the site
### Implementation Details:
- **Framework**: Astro v5.6.1
- **Analytics Package**: @vercel/analytics v2.0.1
- **Integration Method**: Used the `inject()` function approach as documented in Vercel's official quickstart guide
- **Location**: Added to the existing custom Head component which is already configured in astro.config.js
### Verification:
✅ Build completed successfully with no errors
✅ Linter (Prettier) passed with no issues
✅ All existing functionality preserved
✅ Lock file updated to reflect new dependency
### Next Steps:
1. Enable Web Analytics in the Vercel dashboard under the Analytics section for your project
2. Deploy the site to Vercel
3. Verify tracking is working by checking the browser Network tab for `/<unique-path>/view` requests
4. View analytics data in the Vercel dashboard after users visit the site
### Notes:
- The analytics will only collect data when deployed to Vercel
- No additional configuration is needed in the code
- Analytics must be enabled in the Vercel dashboard for the project
- The implementation follows the official Vercel documentation retrieved on June 5, 2026
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
babblebey
approved these changes
Jun 5, 2026
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 Installation Complete
Successfully installed and configured Vercel Web Analytics for this Astro project.
Changes Made:
Installed @vercel/analytics package (v2.0.1)
@vercel/analyticsas a dependency in package.jsonnpm install --legacy-peer-depsto resolve peer dependency conflicts with Vite versionsConfigured Analytics in Head Component
src/components/Head.astroto import and inject Vercel Analyticsimport { inject } from "@vercel/analytics";at the topinject()in the component frontmatter to initialize analyticsImplementation Details:
inject()function approach as documented in Vercel's official quickstart guideVerification:
✅ Build completed successfully with no errors
✅ Linter (Prettier) passed with no issues
✅ All existing functionality preserved
✅ Lock file updated to reflect new dependency
Next Steps:
/<unique-path>/viewrequestsNotes:
View Project · Web Analytics
Created by babblebey with Vercel Agent