-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
Why
Track clicks on outbound links with full server-side context. Use cases:
- Email campaigns - track which links in newsletters get clicked, tied to user identity
- Social sharing - measure traffic from shared links
- Partner/affiliate links - attribute conversions to specific campaigns
- Documentation - see which external resources users find useful
Unlike client-side click tracking, server-side redirects work in emails and capture requests even when JS is disabled.
Requirements
Middleware Handler
packages/core/src/middleware.ts should handle /api/click/[redirect_url]:
- Configurable route path via config
- Collect
serverContextand user info (same as pageView) - Redirect to destination after tracking
URL Handling
The [redirect_url] should support:
- URL-encoded URLs
- Base64-encoded URLs
- Auto-detect format
New Types
Add ClickContext type:
export interface ClickContext {
destination: string;
}GA Backend
Update GA backend to handle click events appropriately.
Notes
- Use
after()for non-blocking tracking before redirect - Handle invalid URLs gracefully
Metadata
Metadata
Assignees
Labels
No labels