Skip to content

Install Vercel Web Analytics - #2

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

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

Conversation

@vercel

@vercel vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown

Vercel Web Analytics Installation Report

Summary

Successfully installed and configured Vercel Web Analytics for this Eleventy-based project following the latest official documentation from https://vercel.com/docs/analytics/quickstart.

Changes Made

Modified Files

  • src/_layouts/main.webc - Added Vercel Web Analytics initialization scripts

What Was Implemented

  1. Clarified Existing Analytics Setup

    • The project already had Vercel Speed Insights installed (script: https://cdn.vercel-insights.com/v1/script.js)
    • Updated the comment to clearly label it as "Speed Insights" to avoid confusion
  2. Added Vercel Web Analytics

    • Added the analytics queue initialization: window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
    • Added the Web Analytics script loader: <script defer src="/_vercel/insights/script.js"></script>
    • Both scripts are added to the <head> section of the main layout template
  3. Package Installation

    • The @vercel/analytics package (v2.0.1) was already present in package.json
    • Ran npm install to ensure all dependencies are properly installed
    • No changes to package.json or package-lock.json were needed

Implementation Details

The implementation follows the recommended approach for static HTML sites from the Vercel documentation:

  • Uses the inline script initialization method which creates a queue system (window.vaq) to buffer analytics calls
  • The deferred script loads asynchronously from /_vercel/insights/script.js (this path is automatically configured by Vercel when Web Analytics is enabled in the dashboard)
  • Both scripts use webc:keep attribute to ensure they're included in the final HTML output

Differences: Web Analytics vs Speed Insights

  • Speed Insights (already installed): Tracks performance metrics like Core Web Vitals and page load times
  • Web Analytics (newly added): Tracks visitor behavior including page views, unique visitors, referrers, demographics, and custom events

Both products work together to provide comprehensive site monitoring and are now properly configured in this project.

Testing

  • Build completed successfully: npm run build
  • Verified that analytics scripts are present in the generated HTML output at dist/index.html
  • Both Speed Insights and Web Analytics scripts are properly included in production builds

Next Steps

To activate Web Analytics:

  1. Enable Web Analytics in the Vercel dashboard (Analytics section of your project)
  2. Deploy the site using vercel deploy
  3. Verify analytics are working by checking the Network tab in browser DevTools for requests to /_vercel/insights/view

Notes

  • The implementation is framework-agnostic and works with Eleventy's WebC template system
  • Analytics scripts are only minimal overhead (~2KB gzipped)
  • Both analytics products respect user privacy and don't use cookies
  • The /_vercel/insights/script.js path is automatically configured by Vercel upon deployment

View Project · Web Analytics

Created by swanson-2669 with Vercel Agent

# Vercel Web Analytics Installation Report

## Summary
Successfully installed and configured Vercel Web Analytics for this Eleventy-based project following the latest official documentation from https://vercel.com/docs/analytics/quickstart.

## Changes Made

### Modified Files
- **src/_layouts/main.webc** - Added Vercel Web Analytics initialization scripts

### What Was Implemented

1. **Clarified Existing Analytics Setup**
   - The project already had Vercel Speed Insights installed (script: `https://cdn.vercel-insights.com/v1/script.js`)
   - Updated the comment to clearly label it as "Speed Insights" to avoid confusion

2. **Added Vercel Web Analytics**
   - Added the analytics queue initialization: `window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };`
   - Added the Web Analytics script loader: `<script defer src="/_vercel/insights/script.js"></script>`
   - Both scripts are added to the `<head>` section of the main layout template

3. **Package Installation**
   - The `@vercel/analytics` package (v2.0.1) was already present in package.json
   - Ran `npm install` to ensure all dependencies are properly installed
   - No changes to package.json or package-lock.json were needed

## Implementation Details

The implementation follows the recommended approach for static HTML sites from the Vercel documentation:
- Uses the inline script initialization method which creates a queue system (`window.vaq`) to buffer analytics calls
- The deferred script loads asynchronously from `/_vercel/insights/script.js` (this path is automatically configured by Vercel when Web Analytics is enabled in the dashboard)
- Both scripts use `webc:keep` attribute to ensure they're included in the final HTML output

## Differences: Web Analytics vs Speed Insights

- **Speed Insights** (already installed): Tracks performance metrics like Core Web Vitals and page load times
- **Web Analytics** (newly added): Tracks visitor behavior including page views, unique visitors, referrers, demographics, and custom events

Both products work together to provide comprehensive site monitoring and are now properly configured in this project.

## Testing

- Build completed successfully: `npm run build`
- Verified that analytics scripts are present in the generated HTML output at `dist/index.html`
- Both Speed Insights and Web Analytics scripts are properly included in production builds

## Next Steps

To activate Web Analytics:
1. Enable Web Analytics in the Vercel dashboard (Analytics section of your project)
2. Deploy the site using `vercel deploy`
3. Verify analytics are working by checking the Network tab in browser DevTools for requests to `/_vercel/insights/view`

## Notes

- The implementation is framework-agnostic and works with Eleventy's WebC template system
- Analytics scripts are only minimal overhead (~2KB gzipped)
- Both analytics products respect user privacy and don't use cookies
- The `/_vercel/insights/script.js` path is automatically configured by Vercel upon deployment

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

vercel Bot commented Mar 26, 2026

Copy link
Copy Markdown
Author

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

Project Deployment Actions Updated (UTC)
projects-site Ready Ready Preview, Comment Mar 26, 2026 7:40pm

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