Skip to content

Add Vercel Web Analytics integration#1

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

Add Vercel Web Analytics integration#1
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/vercel-web-analytics-integrati-kp74dl

Conversation

@vercel

@vercel vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

Implemented Vercel Web Analytics for the Astro project

Overview

Successfully installed and configured Vercel Web Analytics following the latest official documentation from Vercel's quickstart guide and Astro's Vercel adapter documentation.

Changes Made

1. Installed Dependencies

  • @astrojs/vercel@9.0.5: Installed the Astro Vercel adapter (version 9.x to maintain compatibility with Astro 5.x)
    • This adapter enables full Vercel platform integration for Astro projects
    • Provides optimized deployment and edge runtime support

2. Updated Configuration Files

astro.config.mjs

  • Added import vercel from "@astrojs/vercel"
  • Configured output: "server" to enable server-side rendering
  • Added adapter: vercel() to integrate with Vercel's platform
  • Preserved existing Tailwind CSS Vite plugin configuration

package.json

  • Added @astrojs/vercel as a dependency
  • Package lock file (package-lock.json) updated automatically

.gitignore

  • Added .vercel/ directory to exclude Vercel build outputs from version control

3. Existing Analytics Integration

The project already had the Analytics component properly configured:

  • @vercel/analytics@2.0.1 was already installed
  • The <Analytics /> component from @vercel/analytics/astro is already imported and rendered in src/layouts/Layout.astro
  • This is the correct approach for the newer version (2.x+) of @vercel/analytics

Implementation Details

According to the latest Vercel documentation:

  • For @vercel/analytics@2.x+, the recommended approach is to use the Analytics component directly in your layout (already implemented)
  • The webAnalytics.enabled configuration in the adapter is only for older versions (1.3.x or earlier)
  • The Vercel adapter enhances the deployment with platform-specific optimizations

Verification

Build successful: Ran npm run build and confirmed the project builds without errors
Dependencies installed: All packages installed successfully with updated lock file
Configuration valid: Astro accepted the new adapter configuration
Output format: Build now generates Vercel-optimized output at .vercel/output/

Files Modified

  • astro.config.mjs - Added Vercel adapter configuration
  • package.json - Added @astrojs/vercel dependency
  • package-lock.json - Updated with new dependency tree
  • .gitignore - Added .vercel/ build output directory

Next Steps for Deployment

  1. Push these changes to the repository
  2. Link the project to Vercel (if not already linked)
  3. Enable Web Analytics in the Vercel dashboard (Analytics tab → Enable button)
  4. Deploy to production
  5. Verify analytics tracking in browser Network tab (look for requests to /_vercel/insights/*)

Notes

  • The Analytics component in Layout.astro will automatically track page views
  • No additional configuration is needed for basic analytics
  • Custom events can be added later by importing additional functions from @vercel/analytics

View Project · Web Analytics

Created by likeur with Vercel Agent

Implemented Vercel Web Analytics for the Astro project

## Overview
Successfully installed and configured Vercel Web Analytics following the latest official documentation from Vercel's quickstart guide and Astro's Vercel adapter documentation.

## Changes Made

### 1. Installed Dependencies
- **@astrojs/vercel@9.0.5**: Installed the Astro Vercel adapter (version 9.x to maintain compatibility with Astro 5.x)
  - This adapter enables full Vercel platform integration for Astro projects
  - Provides optimized deployment and edge runtime support

### 2. Updated Configuration Files

#### astro.config.mjs
- Added `import vercel from "@astrojs/vercel"`
- Configured `output: "server"` to enable server-side rendering
- Added `adapter: vercel()` to integrate with Vercel's platform
- Preserved existing Tailwind CSS Vite plugin configuration

#### package.json
- Added `@astrojs/vercel` as a dependency
- Package lock file (package-lock.json) updated automatically

#### .gitignore
- Added `.vercel/` directory to exclude Vercel build outputs from version control

### 3. Existing Analytics Integration
The project already had the Analytics component properly configured:
- `@vercel/analytics@2.0.1` was already installed
- The `<Analytics />` component from `@vercel/analytics/astro` is already imported and rendered in `src/layouts/Layout.astro`
- This is the correct approach for the newer version (2.x+) of @vercel/analytics

## Implementation Details

According to the latest Vercel documentation:
- For `@vercel/analytics@2.x+`, the recommended approach is to use the Analytics component directly in your layout (already implemented)
- The `webAnalytics.enabled` configuration in the adapter is only for older versions (1.3.x or earlier)
- The Vercel adapter enhances the deployment with platform-specific optimizations

## Verification

✅ **Build successful**: Ran `npm run build` and confirmed the project builds without errors
✅ **Dependencies installed**: All packages installed successfully with updated lock file
✅ **Configuration valid**: Astro accepted the new adapter configuration
✅ **Output format**: Build now generates Vercel-optimized output at `.vercel/output/`

## Files Modified
- `astro.config.mjs` - Added Vercel adapter configuration
- `package.json` - Added @astrojs/vercel dependency
- `package-lock.json` - Updated with new dependency tree
- `.gitignore` - Added .vercel/ build output directory

## Next Steps for Deployment
1. Push these changes to the repository
2. Link the project to Vercel (if not already linked)
3. Enable Web Analytics in the Vercel dashboard (Analytics tab → Enable button)
4. Deploy to production
5. Verify analytics tracking in browser Network tab (look for requests to `/_vercel/insights/*`)

## Notes
- The Analytics component in Layout.astro will automatically track page views
- No additional configuration is needed for basic analytics
- Custom events can be added later by importing additional functions from @vercel/analytics

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

cloudflare-workers-and-pages Bot commented Jun 16, 2026

Copy link
Copy Markdown

Deploying frameui with  Cloudflare Pages  Cloudflare Pages

Latest commit: d121f6f
Status: ✅  Deploy successful!
Preview URL: https://4a5ac47e.frameui.pages.dev
Branch Preview URL: https://vercel-vercel-web-analytics.frameui.pages.dev

View logs

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Author

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

Project Deployment Actions Updated (UTC)
frame Ready Ready Preview, Comment Jun 16, 2026 5:38pm

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