Skip to content

Install Vercel Web Analytics - #5

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

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

Conversation

@vercel

@vercel vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Vercel Web Analytics Installation

Successfully installed and configured Vercel Web Analytics for the ZenkaiTV project.

Changes Made

1. Package Installation

  • Installed @vercel/analytics@2.0.1 package via npm
  • Updated package.json with the new dependency
  • Updated package-lock.json with dependency tree

2. Analytics Implementation

Created: js/analytics.js

  • Implemented Vercel Analytics initialization using the vanilla JavaScript approach
  • Script dynamically injects the Vercel Analytics tracking script (/_vercel/insights/script.js)
  • Automatically detects production environment (only tracks when deployed to Vercel)
  • Uses the window.va queue pattern for optimal performance

3. HTML Integration

Modified: index.html

  • Added <script defer src="js/analytics.js?v=817"></script> to load analytics
  • Placed after other application scripts but before client.js
  • Uses defer attribute for optimal page load performance

Modified: android/app/src/main/assets/index.html

  • Added matching analytics script tag to maintain Android mirror sync
  • Ensures consistent behavior across web and Android platforms

Created: android/app/src/main/assets/js/analytics.js

  • Copied analytics.js to Android assets directory
  • Maintains file integrity across platforms

Implementation Details

The analytics integration follows Vercel's official documentation for vanilla JavaScript projects:

  1. Script Injection: Uses the /_vercel/insights/script.js path which is automatically provided by Vercel's infrastructure when deployed
  2. Production-Only Tracking: Only activates when deployed (not on localhost)
  3. Queue Pattern: Implements the window.va queue pattern to buffer events before the script loads
  4. Deferred Loading: Uses defer attribute to prevent blocking page render
  5. Build Integration: The build process automatically includes analytics.js in minified output

Verification

✅ Build completed successfully with minified analytics script
✅ Android mirror sync verified - all files byte-identical
✅ Analytics script properly included in dist/ and public/ build outputs
✅ No linting errors introduced (ESLint not configured, but syntax validated)

Next Steps

To complete the analytics setup:

  1. Deploy to Vercel: Run vercel deploy to push changes to production
  2. Enable in Dashboard: Navigate to your project in the Vercel dashboard
    • Go to the Analytics tab
    • Click "Enable Web Analytics"
  3. Verify Tracking: After deployment, check the browser Network tab for requests to /_vercel/insights/view
  4. View Data: Access the analytics dashboard in Vercel to see real-time traffic insights

Files Modified

  • package.json - Added @vercel/analytics dependency
  • package-lock.json - Updated dependency lockfile
  • index.html - Added analytics script tag
  • android/app/src/main/assets/index.html - Added analytics script tag

Files Created

  • js/analytics.js - Analytics initialization script
  • android/app/src/main/assets/js/analytics.js - Android mirror of analytics script
  • .vade-report - This implementation report

Technical Notes

The implementation uses the official Vercel-provided script path (/_vercel/insights/script.js) which:

  • Is automatically available when deployed to Vercel
  • Handles all tracking logic internally
  • Requires no additional configuration beyond enabling in the dashboard
  • Only sends data in production (development events are logged to console)

This approach is recommended over the npm package's inject() function for vanilla JavaScript projects as it:

  • Avoids bundling complexity
  • Leverages Vercel's CDN for optimal script delivery
  • Maintains minimal impact on page load performance
  • Automatically handles version updates

View Project · Web Analytics

Created by juankisantiago-5844 with Vercel Agent

# Vercel Web Analytics Installation

Successfully installed and configured Vercel Web Analytics for the ZenkaiTV project.

## Changes Made

### 1. Package Installation
- Installed `@vercel/analytics@2.0.1` package via npm
- Updated `package.json` with the new dependency
- Updated `package-lock.json` with dependency tree

### 2. Analytics Implementation
**Created**: `js/analytics.js`
- Implemented Vercel Analytics initialization using the vanilla JavaScript approach
- Script dynamically injects the Vercel Analytics tracking script (`/_vercel/insights/script.js`)
- Automatically detects production environment (only tracks when deployed to Vercel)
- Uses the `window.va` queue pattern for optimal performance

### 3. HTML Integration
**Modified**: `index.html`
- Added `<script defer src="js/analytics.js?v=817"></script>` to load analytics
- Placed after other application scripts but before client.js
- Uses defer attribute for optimal page load performance

**Modified**: `android/app/src/main/assets/index.html`
- Added matching analytics script tag to maintain Android mirror sync
- Ensures consistent behavior across web and Android platforms

**Created**: `android/app/src/main/assets/js/analytics.js`
- Copied analytics.js to Android assets directory
- Maintains file integrity across platforms

## Implementation Details

The analytics integration follows Vercel's official documentation for vanilla JavaScript projects:

1. **Script Injection**: Uses the `/_vercel/insights/script.js` path which is automatically provided by Vercel's infrastructure when deployed
2. **Production-Only Tracking**: Only activates when deployed (not on localhost)
3. **Queue Pattern**: Implements the `window.va` queue pattern to buffer events before the script loads
4. **Deferred Loading**: Uses defer attribute to prevent blocking page render
5. **Build Integration**: The build process automatically includes analytics.js in minified output

## Verification

✅ Build completed successfully with minified analytics script
✅ Android mirror sync verified - all files byte-identical
✅ Analytics script properly included in dist/ and public/ build outputs
✅ No linting errors introduced (ESLint not configured, but syntax validated)

## Next Steps

To complete the analytics setup:

1. **Deploy to Vercel**: Run `vercel deploy` to push changes to production
2. **Enable in Dashboard**: Navigate to your project in the Vercel dashboard
   - Go to the Analytics tab
   - Click "Enable Web Analytics"
3. **Verify Tracking**: After deployment, check the browser Network tab for requests to `/_vercel/insights/view`
4. **View Data**: Access the analytics dashboard in Vercel to see real-time traffic insights

## Files Modified
- `package.json` - Added @vercel/analytics dependency
- `package-lock.json` - Updated dependency lockfile
- `index.html` - Added analytics script tag
- `android/app/src/main/assets/index.html` - Added analytics script tag

## Files Created
- `js/analytics.js` - Analytics initialization script
- `android/app/src/main/assets/js/analytics.js` - Android mirror of analytics script
- `.vade-report` - This implementation report

## Technical Notes

The implementation uses the official Vercel-provided script path (`/_vercel/insights/script.js`) which:
- Is automatically available when deployed to Vercel
- Handles all tracking logic internally
- Requires no additional configuration beyond enabling in the dashboard
- Only sends data in production (development events are logged to console)

This approach is recommended over the npm package's `inject()` function for vanilla JavaScript projects as it:
- Avoids bundling complexity
- Leverages Vercel's CDN for optimal script delivery
- Maintains minimal impact on page load performance
- Automatically handles version updates

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

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

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

Project Deployment Actions Updated
animetv Ready Ready Preview, v0 Sep 18, 2026 3:55am UTC
zenkaitv-scraper Ready Ready Preview Sep 18, 2026 3:55am UTC

Request Review

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