Skip to content

feat: implement email click tracking and custom redirect handler (#259)#268

Open
CodeSparks45 wants to merge 1 commit into
Kuldeeep18:mainfrom
CodeSparks45:fix-issue-259-click-tracking
Open

feat: implement email click tracking and custom redirect handler (#259)#268
CodeSparks45 wants to merge 1 commit into
Kuldeeep18:mainfrom
CodeSparks45:fix-issue-259-click-tracking

Conversation

@CodeSparks45

Copy link
Copy Markdown

This PR introduces a robust click-tracking mechanism for outbound campaign emails. It parses outgoing email bodies, rewrites anchor tags with a secure tracking URL, and handles the redirection while updating lead analytics.

Closes #259

Key Changes:

tasks.py: Implemented rewrite_email_links using BeautifulSoup to parse HTML. Used Django's cryptographic Signer to securely encode the campaign_lead_id and step_id within the tracking URL to prevent tampering. Intercepted the email body just before send_gmail.

views.py: Added ClickTrackingView (unauthenticated API endpoint). This decodes the secure token, updates the last_clicked_at timestamp on the specific CampaignLead, and gracefully handles the HttpResponseRedirect to the original URL.

urls.py: Registered the new /api/v1/clicks/track/ route for the interceptor.

Testing Performed:

Verified the link rewriting logic locally to ensure secure tokens generate correctly.

Tested the tracking endpoint to ensure it safely decodes the payload, updates database metrics, and redirects to the target destination without error.

@Kuldeeep18

Copy link
Copy Markdown
Owner

🚀 PR Guidelines — Read Before Raising a PR

Hey contributors 👋

I’m LeadOrbit's Bot, and I’ll review every PR before it gets merged.

✅ Your PR will only be merged if:

  • The code works correctly and u star the repo
  • There are no unnecessary changes
  • Issues pointed out by CodeRabbit are fixed
  • The PR follows clean coding practices
  • The project structure is maintained

❌ PRs that may be rejected:

  • Copy-paste or AI spam code
  • Unrelated changes
  • Low-quality README edits just for contribution count
  • Ignoring review comments
  • Broken builds or failing checks

Before submitting:

  1. Run and test your code properly
  2. Resolve all CodeRabbit suggestions
  3. Keep your PR focused and clean

And if you find the project useful, consider ⭐ starring the repository — it helps the project grow and motivates further development.

Quality contributions > PR count.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LO-062 [Hard]: Email Click Tracking Link Wrapper (Custom Redirect Handler)

2 participants