Install Vercel Web Analytics Integration - #1
Merged
ZelinZhou-THU merged 1 commit intoMay 26, 2026
Conversation
Implemented Vercel Web Analytics for stem-tutor-agent project. ## What was implemented: Added Vercel Web Analytics to the FastAPI application following the latest official documentation for vanilla HTML projects. ## Files Modified: - **web/templates/index.html** - Added Vercel Analytics scripts to the <head> section ## Implementation Details: Since this is a FastAPI (Python) project with a vanilla HTML/JavaScript frontend (not a Node.js/npm-based project), I used the script tag approach recommended by Vercel for frameworks-less projects. Added two scripts to the HTML head section: 1. Analytics initialization script that creates the `window.va` function and queue 2. Deferred loading of the Vercel insights script from `/_vercel/insights/script.js` This approach: - Does NOT require npm or package.json modifications - Works with vanilla HTML/JavaScript - Automatically tracks page views and user interactions - Integrates seamlessly with Vercel's deployment platform ## How it works: When deployed to Vercel: 1. The `/_vercel/insights/script.js` path is automatically served by Vercel's infrastructure 2. Analytics data is collected and sent to Vercel's analytics dashboard 3. No additional configuration needed - it works out of the box once deployed ## Testing: After deployment to Vercel, analytics can be verified by: 1. Navigating to the Vercel dashboard → Project → Analytics 2. Checking browser Network tab for requests to `/_vercel/insights/` paths 3. Viewing real-time analytics data in the Vercel dashboard ## Reference: Implementation follows the official Vercel documentation: - Quickstart guide: https://vercel.com/docs/analytics/quickstart - Vanilla HTML approach from community: https://community.vercel.com/t/using-vercels-analytics-with-no-framework/3194 No package.json or lockfile changes were needed as this is a Python project and the analytics are loaded via script tags at runtime. Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Contributor
Author
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Implemented Vercel Web Analytics for stem-tutor-agent project.
What was implemented:
Added Vercel Web Analytics to the FastAPI application following the latest official documentation for vanilla HTML projects.
Files Modified:
Implementation Details:
Since this is a FastAPI (Python) project with a vanilla HTML/JavaScript frontend (not a Node.js/npm-based project), I used the script tag approach recommended by Vercel for frameworks-less projects.
Added two scripts to the HTML head section:
window.vafunction and queue/_vercel/insights/script.jsThis approach:
How it works:
When deployed to Vercel:
/_vercel/insights/script.jspath is automatically served by Vercel's infrastructureTesting:
After deployment to Vercel, analytics can be verified by:
/_vercel/insights/pathsReference:
Implementation follows the official Vercel documentation:
No package.json or lockfile changes were needed as this is a Python project and the analytics are loaded via script tags at runtime.
View Project · Web Analytics
Created by ZHOU Zelin (zelinzhou-thu) with Vercel Agent