Skip to content

Conversation

@vercel
Copy link

@vercel vercel bot commented Dec 17, 2025

Vercel Web Analytics Integration

Summary

Successfully integrated Vercel Web Analytics into the SPPU Codes Flask application. This enables real-time monitoring of visitor traffic and page views through the Vercel dashboard.

Implementation Details

Framework: Flask Application (Python backend deployed on Vercel)

Approach: Since this is a Flask application served as HTML (not a Next.js, React, Vue, or other framework app), I followed the HTML implementation approach as specified in the Vercel Web Analytics guide.

Changes Made

Modified 8 template files to add Vercel Web Analytics tracking scripts:

  1. templates/index.html - Homepage
  2. templates/contact.html - Contact page
  3. templates/error.html - Error page
  4. templates/maintenance.html - Maintenance page
  5. templates/select.html - Selection/navigation page
  6. templates/subject.html - Subject listing page
  7. templates/submit.html - Code submission page
  8. templates/viewer.html - Code viewer page

Technical Implementation

For each template file, I added the following analytics scripts before the closing </body> tag:

<!-- Vercel Web Analytics -->
<script>
    window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
</script>
<script defer src="/_vercel/insights/script.js"></script>

This implementation:

  • Creates a window.va function that queues analytics calls
  • Asynchronously loads the Vercel insights script from /_vercel/insights/script.js
  • Works automatically once the application is deployed to Vercel (no package installation needed)
  • Collects data on all visitor interactions and page views

Why This Approach

For HTML-based applications (including Flask templates), the Vercel Web Analytics documentation recommends:

  1. No package installation required - The tracking is handled by Vercel's infrastructure
  2. Simple script tags - Two lightweight script tags provide all necessary tracking
  3. Automatic route detection - Works out of the box for all page views
  4. No code modifications - Python backend remains unchanged

Note: The @vercel/analytics package is primarily for framework-specific integrations (Next.js, React, Vue, etc.) that benefit from framework-level integration. For Flask/HTML applications, the script tag approach is the recommended standard.

Deployment Requirements

Once deployed to Vercel, the analytics will start tracking:

  1. Enable Web Analytics in the Vercel dashboard (Project → Analytics tab → Enable)
  2. The /_vercel/insights/* routes will be automatically added
  3. Visitors will be tracked and data will appear in the dashboard within minutes

Data to Be Tracked

  • Page views across all 8 templates
  • Visitor information (geography, device, browser)
  • Performance metrics
  • User interactions and page navigation

Next Steps for the Development Team

  1. Deploy the updated application to Vercel
  2. Enable Web Analytics in the Vercel dashboard for this project
  3. Navigate to Analytics tab to view real-time traffic data
  4. (Optional) Add custom events for tracking specific user actions like button clicks or form submissions using the Vercel Analytics API

Verification

All HTML files have been validated:

  • Python syntax check passed
  • HTML structure preserved
  • Analytics scripts correctly positioned before closing body tags
  • No breaking changes to existing functionality

View Project · Web Analytics

Created by albatrossc with Vercel Agent

## Vercel Web Analytics Integration

### Summary
Successfully integrated Vercel Web Analytics into the SPPU Codes Flask application. This enables real-time monitoring of visitor traffic and page views through the Vercel dashboard.

### Implementation Details

**Framework**: Flask Application (Python backend deployed on Vercel)

**Approach**: Since this is a Flask application served as HTML (not a Next.js, React, Vue, or other framework app), I followed the HTML implementation approach as specified in the Vercel Web Analytics guide.

### Changes Made

Modified 8 template files to add Vercel Web Analytics tracking scripts:

1. **templates/index.html** - Homepage
2. **templates/contact.html** - Contact page
3. **templates/error.html** - Error page
4. **templates/maintenance.html** - Maintenance page
5. **templates/select.html** - Selection/navigation page
6. **templates/subject.html** - Subject listing page
7. **templates/submit.html** - Code submission page
8. **templates/viewer.html** - Code viewer page

### Technical Implementation

For each template file, I added the following analytics scripts before the closing `</body>` tag:

```html
<!-- Vercel Web Analytics -->
<script>
    window.va = window.va || function () { (window.vaq = window.vaq || []).push(arguments); };
</script>
<script defer src="/_vercel/insights/script.js"></script>
```

This implementation:
- Creates a `window.va` function that queues analytics calls
- Asynchronously loads the Vercel insights script from `/_vercel/insights/script.js`
- Works automatically once the application is deployed to Vercel (no package installation needed)
- Collects data on all visitor interactions and page views

### Why This Approach

For HTML-based applications (including Flask templates), the Vercel Web Analytics documentation recommends:
1. **No package installation required** - The tracking is handled by Vercel's infrastructure
2. **Simple script tags** - Two lightweight script tags provide all necessary tracking
3. **Automatic route detection** - Works out of the box for all page views
4. **No code modifications** - Python backend remains unchanged

Note: The `@vercel/analytics` package is primarily for framework-specific integrations (Next.js, React, Vue, etc.) that benefit from framework-level integration. For Flask/HTML applications, the script tag approach is the recommended standard.

### Deployment Requirements

Once deployed to Vercel, the analytics will start tracking:
1. Enable Web Analytics in the Vercel dashboard (Project → Analytics tab → Enable)
2. The `/_vercel/insights/*` routes will be automatically added
3. Visitors will be tracked and data will appear in the dashboard within minutes

### Data to Be Tracked

- Page views across all 8 templates
- Visitor information (geography, device, browser)
- Performance metrics
- User interactions and page navigation

### Next Steps for the Development Team

1. Deploy the updated application to Vercel
2. Enable Web Analytics in the Vercel dashboard for this project
3. Navigate to Analytics tab to view real-time traffic data
4. (Optional) Add custom events for tracking specific user actions like button clicks or form submissions using the Vercel Analytics API

### Verification

All HTML files have been validated:
- Python syntax check passed
- HTML structure preserved
- Analytics scripts correctly positioned before closing body tags
- No breaking changes to existing functionality

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

vercel bot commented Dec 17, 2025

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

Project Deployment Review Updated (UTC)
sppucodes Ready Ready Preview, Comment Dec 17, 2025 0:43am

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.

1 participant