Skip to content

Install Vercel Web Analytics Integration - #6

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

Install Vercel Web Analytics Integration#6
vercel[bot] wants to merge 1 commit into
mainfrom
vercel/install-vercel-web-analytics-i-6bvkd9

Conversation

@vercel

@vercel vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

Implemented Vercel Web Analytics for the SCOM project.

Changes Made

Modified:

  • templates/base.html - Added Vercel Web Analytics script tag to the section

Implementation Details

This is a Python-based FastAPI/Starlette project with Jinja2 HTML templates. Based on the latest official Vercel documentation, I implemented Web Analytics using the recommended approach for HTML-based projects:

  1. Fetched Latest Documentation: Retrieved the current installation instructions from Vercel's official documentation (https://vercel.com/docs/analytics/quickstart) and examined the official HTML example (https://github.com/vercel/examples/tree/main/solutions/html).

  2. Identified Framework: Determined that this is a Python FastAPI application serving HTML templates via Jinja2, not a JavaScript framework (Next.js, React, Vue, etc.).

  3. Applied Correct Integration Method: For non-JavaScript frameworks and HTML-based projects, Vercel Web Analytics is integrated by adding a single script tag to the HTML:

    <script defer src="/_vercel/insights/script.js"></script>
  4. Added to Base Template: Inserted the analytics script in the <head> section of templates/base.html. Since all other templates extend from base.html, this ensures analytics tracking is enabled across the entire website.

Why This Approach

  • The @vercel/analytics npm package is designed for JavaScript frameworks (Next.js, React, Vue, etc.)
  • For Python/FastAPI projects with HTML templates, Vercel automatically provides the analytics script at /_vercel/insights/script.js when deployed
  • The script uses the defer attribute for optimal loading performance without blocking page rendering
  • No package manager changes are needed since this is purely a server-side rendered application

Next Steps

After deployment to Vercel:

  1. Enable Web Analytics in the Vercel Dashboard (Analytics section → Enable button)
  2. Deploy the application to activate analytics tracking
  3. Verify tracking by checking browser Network tab for requests to /_vercel/insights/
  4. View analytics data through the Vercel Dashboard

Verification

  • ✓ Python syntax validated successfully
  • ✓ All templates inherit from base.html, ensuring site-wide coverage
  • ✓ Script tag follows official Vercel HTML example best practices
  • ✓ No dependencies to install (pure HTML/script integration)

View Project · Web Analytics

Created by Mbugua (mbugua) with Vercel Agent

Implemented Vercel Web Analytics for the SCOM project.

## Changes Made

Modified:
- templates/base.html - Added Vercel Web Analytics script tag to the <head> section

## Implementation Details

This is a Python-based FastAPI/Starlette project with Jinja2 HTML templates. Based on the latest official Vercel documentation, I implemented Web Analytics using the recommended approach for HTML-based projects:

1. **Fetched Latest Documentation**: Retrieved the current installation instructions from Vercel's official documentation (https://vercel.com/docs/analytics/quickstart) and examined the official HTML example (https://github.com/vercel/examples/tree/main/solutions/html).

2. **Identified Framework**: Determined that this is a Python FastAPI application serving HTML templates via Jinja2, not a JavaScript framework (Next.js, React, Vue, etc.).

3. **Applied Correct Integration Method**: For non-JavaScript frameworks and HTML-based projects, Vercel Web Analytics is integrated by adding a single script tag to the HTML:
   ```html
   <script defer src="/_vercel/insights/script.js"></script>
   ```

4. **Added to Base Template**: Inserted the analytics script in the `<head>` section of `templates/base.html`. Since all other templates extend from base.html, this ensures analytics tracking is enabled across the entire website.

## Why This Approach

- The `@vercel/analytics` npm package is designed for JavaScript frameworks (Next.js, React, Vue, etc.)
- For Python/FastAPI projects with HTML templates, Vercel automatically provides the analytics script at `/_vercel/insights/script.js` when deployed
- The script uses the `defer` attribute for optimal loading performance without blocking page rendering
- No package manager changes are needed since this is purely a server-side rendered application

## Next Steps

After deployment to Vercel:
1. Enable Web Analytics in the Vercel Dashboard (Analytics section → Enable button)
2. Deploy the application to activate analytics tracking
3. Verify tracking by checking browser Network tab for requests to `/_vercel/insights/`
4. View analytics data through the Vercel Dashboard

## Verification

- ✓ Python syntax validated successfully
- ✓ All templates inherit from base.html, ensuring site-wide coverage
- ✓ Script tag follows official Vercel HTML example best practices
- ✓ No dependencies to install (pure HTML/script integration)

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

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown
Author

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

Project Deployment Actions Updated (UTC)
scom Ready Ready Preview Aug 31, 2026 5:03am

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