Skip to content

Enterprise-grade serverless email open intelligence platform implementing pixel-based event capture, Vercel Edge Functions, Google Apps Script webhooks, Sheets-backed event ledger, real-time Gmail alerts, cache-busted telemetry, metadata enrichment, & stateless, cloud-native observability pipelines for scalable email analytics & growth engineering.

Notifications You must be signed in to change notification settings

bitsandbrains/serverless-email-open-intelligence-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Email Open Tracker

1. ๐Ÿงฉ Project Overview

A lightweight, serverless, real-time email open tracking system combining Vercel Serverless Functions, Google Apps Script Webhooks, and Google Sheets. The system captures when an email recipient opens a tracked email by loading a 1ร—1 tracking pixel.

It logs metadata (IP, user agent, timestamp) and sends instant Gmail notifications every time the email is opened.


2. ๐ŸŽฏ Objectives & Goals

  • Track every email open event in real time.
  • Log each event into Google Sheets for audit and analytics.
  • Forward metadata to Google Apps Script for processing.
  • Send Gmail notifications automatically.
  • Deploy a minimal, scalable, costโ€‘free solution leveraging serverless infrastructure.

3. โœ… Acceptance Criteria

  • Pixel endpoint must respond with a valid 1ร—1 GIF.
  • Logs must appear in Google Sheets with correct schema.
  • Gmail notifications must trigger on every open.
  • System must operate without a backend server or database.
  • Endpoint must handle repeated opens.
  • Deployed on Vercel with environment variable support.

4. ๐Ÿ’ป Prerequisites

  • Git & GitHub account
  • Vercel account
  • Google Account (for Sheets & Apps Script)
  • Node.js 18+ (optional for local testing)
  • Basic understanding of serverless functions

5. โš™๏ธ Installation & Setup

Clone the repository

git clone https://github.com/<your-username>/email-open-tracker.git
cd email-open-tracker

Folder Structure

email-open-tracker/
 โ”œโ”€โ”€ api/
 โ”‚    โ””โ”€โ”€ open.js
 โ”œโ”€โ”€ package.json
 โ”œโ”€โ”€ .gitignore
 โ””โ”€โ”€ README.md

Install Dependencies (if needed)

npm install

Configure Vercel Environment Variable

APPSCRIPT_WEBHOOK=<Your Google Apps Script URL>

Deploy

vercel --prod

6. ๐Ÿ”— API Documentation

Endpoint

GET /api/open?mid=<mail_id>&v=<nonce>

Query Parameters

Param Type Required Description
mid string yes Unique email/message ID
v string no Random value to avoid caching

Response

  • Content-Type: image/gif
  • 1ร—1 transparent tracking pixel

7. ๐Ÿ–ฅ๏ธ UI / Frontend

This project does not include a UI. It is a pure backend pixel-tracking architecture.

If UI is added later, include:

  • Dashboard for logs
  • Table component for events
  • Real-time updates via WebSockets or Polling

8. ๐Ÿ”ข Status Codes

Code Meaning
200 Pixel delivered successfully
500 Internal serverless function error
400 Missing or invalid query parameters

9. ๐Ÿš€ Features

  • Unlimited email open tracking
  • Serverless, scalable, zero-cost model
  • Instant Gmail notifications
  • Logs maintained in Google Sheets
  • Fully stateless API

10. ๐Ÿงฑ Tech Stack & Architecture

  • Vercel Serverless Functions โ†’ pixel endpoint
  • Google Apps Script โ†’ webhook processor & email sender
  • Google Sheets โ†’ open-event storage
  • JavaScript (Node.js)
  • HTTP-based pixel tracking

11. ๐Ÿ› ๏ธ Workflow & Implementation

  1. Configure Google Sheet with header schema
  2. Write Apps Script webhook handler
  3. Deploy the script and get public URL
  4. Add URL to Vercel environment variables
  5. Build /api/open.js serverless function
  6. Deploy to Vercel
  7. Embed pixel in outbound email
  8. Logs appear in Sheets
  9. Gmail sends real-time notifications

12. ๐Ÿงช Testing & Validation

Test Case Input Expected Output
Pixel Load URL hit GIF + Sheet Row
Multiple Opens Same email Multiple log rows
Missing mid URL without mid 400 error
Apps Script Down Webhook unreachable Pixel still loads

13. ๐Ÿ” Validation Summary

  • End-to-end flow validated for repeated open events
  • Verified pixel caching disabled (via v param)
  • Verified Sheets + Gmail notification latency ~1โ€“2 seconds

14. ๐Ÿงฐ Verification Tools & Examples

  • cURL
curl "https://your-app.vercel.app/api/open?mid=test123&v=111"
  • Postman/Thunder Client
  • Google Chrome Network Inspector

15. ๐Ÿงฏ Troubleshooting

Issue Fix
Pixel not firing Add v query param to avoid cache
No logs Verify Apps Script URL in Vercel
No Gmail notification Check permissions in Apps Script
500 error Missing env variable

16. ๐Ÿ”’ Security & Secrets

  • Do not expose Apps Script URL in public repos
  • Use HTTPS pixel endpoint
  • Use long random mid to avoid enumeration attacks

17. โ˜๏ธ Deployment

Vercel

  • Auto-builds API route
  • Instant CDN-based scaling

Netlify / GitHub Pages

  • Not supported for serverless API required by pixel tracking

18. โšก Quick-Start Cheat Sheet

1. Deploy Apps Script
2. Set APPSCRIPT_WEBHOOK in Vercel
3. Deploy to Vercel
4. Use pixel in email
5. Track opens in Sheets

19. ๐Ÿงพ Usage Notes

  • Use unique mid for each email user
  • Add cache busters using v=<timestamp>
  • Pixel loads silentlyโ€”no UI

20. ๐Ÿง  Performance & Optimization

  • Serverless cold start minimal
  • Uses fast, stateless HTTP requests
  • Apps Script batching possible for future scaling

21. ๐ŸŒŸ Enhancements

  • Dashboard UI
  • Analytics charts
  • Geo-IP enhancements
  • Event batching

22. ๐Ÿงฉ Maintenance & Future Work

  • Rotate script endpoints periodically
  • Add IP anonymization for GDPR compliance
  • Add retry queue if Apps Script is down

23. ๐Ÿ† Key Achievements

  • Achieved 100% serverless, zero-infrastructure system
  • Near real-time event tracking
  • Infinite scalability using Vercel + Google Apps Script

24. ๐Ÿงฎ High-Level Architecture

Email Client โ†’ Vercel Pixel API โ†’ Google Apps Script โ†’ Google Sheets + Gmail Notification

25. ๐Ÿ—‚๏ธ Folder Structure

email-open-tracker/
 โ”œโ”€โ”€ api/
 โ”‚    โ””โ”€โ”€ open.js
 โ”œโ”€โ”€ .gitignore
 โ”œโ”€โ”€ package.json
 โ””โ”€โ”€ README.md

26. ๐Ÿงญ How to Demonstrate Live

  1. Deploy to Vercel
  2. Send email with:
<img src="https://your-app.vercel.app/api/open?mid=demo123&v=1" />
  1. Open email from multiple devices
  2. Show real-time Sheet logs and Gmail notifications

27. ๐Ÿ’ก Summary & Closure

This project provides a production-grade, serverless email open tracking solution with zero infrastructure cost and instant scalability. Leveraging Vercel + Google Apps Script ensures quick deployments, real-time notifications, and a clean, fault-tolerant architecture suitable for enterprise-grade tracking pipelines.

All components are modular, extensible, and aligned with modern web engineering standards.

About

Enterprise-grade serverless email open intelligence platform implementing pixel-based event capture, Vercel Edge Functions, Google Apps Script webhooks, Sheets-backed event ledger, real-time Gmail alerts, cache-busted telemetry, metadata enrichment, & stateless, cloud-native observability pipelines for scalable email analytics & growth engineering.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published