Prompt
How do I track email opens, clicks, bounces, and deliveries in my product?
Latest observation
To track opens, clicks, bounces, and deliveries in your product, you usually need two pieces:
- An email sending provider that supports event webhooks
- A backend endpoint in your app to receive and store those events
1) Use your email provider’s event webhooks
Most transactional email providers can notify you when an email is:
- Delivered
- Opened
- Clicked
- Bounced
- Sometimes also: dropped, deferred, spam complaint, unsubscribed
Examples:
- SendGrid
- Mailgun
- Postmark
- Amazon SES + SNS
- Resend
- Mailchimp Transactional
You configure the provider to POST event data to a webhook in your app.
2) Include a unique tracking ID in each email
When you send an email, generate or store an internal ID for that message.
Example fields:
message_iduser_idemail_templatecampaign_idrecipient_email
Then send the email with that ID attached via:
- provider metadata
- custom args / tags
- headers
This lets you match webhook events back to the right user/email in your database.
3) Store events in your database
Create an email-events table like:
email_events (
id,
message_id,
user_id,
event_type, -- delivered, opened, clicked, bounced
event_time,
url, -- for click events
ip_address,
user_agent,
raw_payload
)
Then update a summary table or denormalized status per message:
email_deliveries (
message_id,
status, -- sent, delivered, opened, clicked, bounced
delivered_at,
opened_at,
clicked_at,
bounced_at
)
4) Set up a webhook endpoint
Your app needs an endpoint like:
POST /webhooks/email-events
That endpoint should:
- verify the request signature from the provider
- parse the event
- deduplicate events if needed
- store the event
- update the message status
Important:
- Providers often send the same event more than once
- Opens/clicks can happen multiple times
- You should treat them as events, not just one final state
5) How each event is usually tracked
Delivery
Usually comes from the provider when the recipient’s mail server accepted the message.
Open
Tracked using a tiny invisible image pixel in the email.
When the email client loads the image, it triggers an open event.
Caveat:
- Open tracking is imperfect now because of privacy features like Apple Mail Privacy Protection, image blocking, and email security proxies.
Click
Tracked by rewriting links through a redirect URL owned by the provider or your app.
Example:
- Original:
https://yourdomain.com/pricing - Tracked:
https://track.yourdomain.com/click/abc123 - The tracking URL logs the click, then redirects to the original URL
Bounce
Reported by the provider when delivery fails.
Types:
- Hard bounce: invalid email, permanent failure
- Soft bounce: temporary issue like mailbox full
6) Track the user journey in your product
Once you store events, you can show:
- Email sent
- Delivered
- Opened
- Clicked
- Bounced
You can also calculate:
- Delivery rate
- Open rate
- Click-through rate
- Bounce rate
Example metrics:
- Delivery rate = delivered / sent
- Open rate = opened / delivered
- CTR = clicked / delivered
- Bounce rate = bounced / sent
7) If you want to implement it yourself
If you are not relying entirely on provider analytics, the standard architecture is:
- App sends email with tracking token
- Links in email go through your redirect endpoint
- Tracking pixel points to your image endpoint
- Webhook receives provider delivery/bounce events
- Backend stores everything in DB
- Dashboard reads from DB
8) Important caveats
- Opens are approximate, not fully reliable
- Clicks are more reliable than opens
- Delivery means accepted by recipient server, not necessarily inboxed
- Bounces must be handled to suppress bad addresses
- Respect privacy laws and user consent where applicable
9) Recommended approach
If you’re building a product, the simplest and most reliable path is:
- Use a provider with webhook event support
- Use their delivery/open/click/bounce tracking
- Store events in your own database
- Build your analytics and product UI on top of that
If you want, I can also show you:
- a database schema
- a sample webhook handler
- a Node.js / Python / Go implementation
- or how to do this with a specific provider like SendGrid, Postmark, SES, or Resend