feat(redirect): optional click-id passthrough on web destinations#30
Merged
Merged
Conversation
Add an opt-in (default off) per-link capability to append ?lf_click=<click id> to HTTP(S) redirect destinations, so a downstream tool can correlate a landing visit back to the exact click that sent it. The click id is generated up front (rather than defaulted by the DB on insert) so the synchronous redirect carries the same id the asynchronous click row is written with. Controlled per link via a new links.append_click_id column, default false — the redirect never alters a destination's query string unless explicitly enabled. App scheme / deep-link destinations are never modified; web/HTTPS only.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in (default off) per-link capability to append
?lf_click=<click id>to HTTP(S) redirect destinations, so a downstream tool can correlate a landing visit back to the exact click that sent it (industry-standard click-id passthrough, à lagclid/fbclid).Why / Usage
Every click is already recorded in
click_events, but that click id never leaves the server - so a destination site can't tie a later conversion back to the specific click that drove it. This adds the standard click-identifier passthrough (the same pattern asgclid,fbclid,msclkid): when enabled, the redirect forwards the click's id on the destination URL aslf_click, so first-party analytics or your own backend can correlate the landing visit - and any downstream conversion - to that exact row inclick_events. This makes per-click attribution possible without any extra server round-trip.Example. A link points to
https://shop.example/landing. Withappend_click_idenabled, the visitor lands onhttps://shop.example/landing?lf_click=<uuid>; the page reads the param and stores it alongside the resulting signup/purchase, so conversions can be attributed to individual clicks. It's opt-in and default-off, so destination URLs are left untouched unless you turn it on per link.Details
links.append_click_idcolumn, defaultfalse- the redirect never alters a destination's query string unless a link explicitly opts in. [CREATE TABLE] [idempotent ALTER]Tests
npm test- 132 passing (incl. 32 redirect tests).