Repository navigation
Install Vercel Web Analytics - #4
Merged
Merged
Conversation
# Vercel Web Analytics Installation Report ## Summary Successfully installed and configured Vercel Web Analytics for the pietrouni.com project. ## Changes Made ### 1. Package Installation - **Added dependency**: `@vercel/analytics` v2.0.1 - **Files modified**: - `package.json` - Added @vercel/analytics to dependencies - `package-lock.json` - Updated with new dependency tree ### 2. Analytics Integration - **File modified**: `src/main.ts` - **Changes**: - Added import statement for the `inject` function from `@vercel/analytics` - Added `inject()` call in the DOMContentLoaded event handler, right after `initTheme()` - Placed strategically to ensure analytics initializes early in the application lifecycle ### 3. Implementation Details Following the official Vercel Web Analytics documentation (https://vercel.com/docs/analytics/quickstart), I used the vanilla JavaScript/Vite approach: - Used the `inject()` function from `@vercel/analytics` package - This is the recommended approach for vanilla TypeScript/JavaScript projects with Vite - The `inject()` function automatically: - Initializes the analytics queue - Loads the Vercel Analytics script - Handles development vs production modes - Tracks page views and custom events ### 4. Verification ✅ Build completed successfully (`npm run build`) ✅ All tests pass (58 tests across 5 test files) ✅ No TypeScript errors introduced ✅ Lock file updated correctly ## Next Steps To enable Web Analytics in production: 1. Navigate to your Vercel project dashboard 2. Go to the Analytics section 3. Click "Enable Web Analytics" 4. Deploy this code to Vercel Once deployed, analytics data will start appearing in the Vercel dashboard, showing: - Page views and unique visitors - Top pages and referrers - Device and browser statistics - Geographic distribution of visitors ## Technical Notes - The analytics script is loaded asynchronously and won't block page rendering - In development mode, analytics events are logged but not sent to the server - The implementation respects ad blockers and privacy preferences - Zero impact on bundle size (script is loaded externally by Vercel) Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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 Report
Summary
Successfully installed and configured Vercel Web Analytics for the pietrouni.com project.
Changes Made
1. Package Installation
@vercel/analyticsv2.0.1package.json- Added @vercel/analytics to dependenciespackage-lock.json- Updated with new dependency tree2. Analytics Integration
src/main.tsinjectfunction from@vercel/analyticsinject()call in the DOMContentLoaded event handler, right afterinitTheme()3. Implementation Details
Following the official Vercel Web Analytics documentation (https://vercel.com/docs/analytics/quickstart), I used the vanilla JavaScript/Vite approach:
inject()function from@vercel/analyticspackageinject()function automatically:4. Verification
✅ Build completed successfully (
npm run build)✅ All tests pass (58 tests across 5 test files)
✅ No TypeScript errors introduced
✅ Lock file updated correctly
Next Steps
To enable Web Analytics in production:
Once deployed, analytics data will start appearing in the Vercel dashboard, showing:
Technical Notes
View Project · Web Analytics
Created by pietrouni-1351 with Vercel Agent