Skip to content

feat: Auto-track all links and views without manual configuration #2880

@ilhamsj

Description

@ilhamsj

Is your feature request related to a problem? Please describe.

Yes. Currently, users must manually track links and views in campaigns:

  1. Link tracking: Users must either:

    • Add @TrackLink suffix to URLs (e.g., https://example.com@TrackLink)
    • Use {{ TrackLink "url" }} template syntax
    • Check the "Track link?" checkbox in the rich text editor for each link
  2. View tracking: Users must manually insert {{ TrackView }} in email templates.

This is error-prone:

  • Users forget to track links, leading to incomplete analytics
  • Users forget to add {{ TrackView }}, missing open tracking
  • Manual work slows campaign creation
  • New users may not know about these features

Describe the solution you'd like

Automatically track all links and views without manual steps:

  1. Automatic link tracking:

    • Automatically wrap all URLs in campaign content with {{ TrackLink }} during template compilation
    • Exclude system URLs (UnsubscribeURL, MessageURL, ManageURL, OptinURL) to avoid double-tracking
    • Preserve existing manual @TrackLink or {{ TrackLink }} usage for backward compatibility
  2. Automatic view tracking:

    • Automatically insert {{ TrackView }} before the closing </body> tag (or at the end if no body tag exists)
    • Skip insertion if {{ TrackView }} already exists in the template

Technical implementation approach

  1. Auto TrackLink (in models/campaigns.go - CompileTemplate()):

    • Parse HTML in campaign body using Go's html package
    • Find all <a href="..."> tags
    • Replace URLs with {{ TrackLink "url" . }} except for system URLs
    • Process after markdown conversion (if applicable) but before template compilation
  2. Auto TrackView (in models/campaigns.go - CompileTemplate()):

    • Check if {{ TrackView }} exists in template body
    • If not, append it before </body> or at the end of the template
    • Process during template compilation phase

Why this makes sense for the project

  • Improves UX: removes manual steps and reduces errors
  • Better analytics: ensures consistent tracking
  • Backward compatible: existing manual tracking continues to work
  • Aligns with common email marketing tools that auto-track by default
  • Low risk: changes are in template compilation, not core functionality

Additional context

  • The rich text editor already defaults the "Track link?" checkbox to true (line 277 in RichtextEditor.vue), indicating intent for tracking by default
  • Current tracking infrastructure supports this; we just need to automate the application

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions