Skip to content

Add click tracking support #11

Description

@vklimontovich

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 serverContext and 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions