🔧 ProgrammierungRequest lifecycle: HandlerMapping HandlerAdapter resolvers(16.09.2026 um 00:08 Uhr)
🔧 ProgrammierungChapter 1 - The Funkiest of All Machines(16.09.2026 um 00:13 Uhr)
🔧 AI Nachrichten President Trump Called Nvidia’s Jensen Huang About A.I. Slowdown(15.09.2026 um 23:45 Uhr)
🔧 AI Nachrichten Google’s Simulated Fruit Fly Brain Did Not Write This Article(16.09.2026 um 00:00 Uhr)
🔧 ProgrammierungRequest lifecycle: HandlerMapping HandlerAdapter resolvers(16.09.2026 um 00:08 Uhr)
🔧 ProgrammierungChapter 1 - The Funkiest of All Machines(16.09.2026 um 00:13 Uhr)
🔧 AI Nachrichten President Trump Called Nvidia’s Jensen Huang About A.I. Slowdown(15.09.2026 um 23:45 Uhr)
🔧 AI Nachrichten Google’s Simulated Fruit Fly Brain Did Not Write This Article(16.09.2026 um 00:00 Uhr)

🔧 Programmierung 🕛 vor 3 Monaten 2 Min Lesezeit
0

How to persist landing page attribution across OAuth redirects (30 lines of middleware)

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Landing page attribution breaks the moment a user hits an OAuth flow.



Here's the scenario: you're running ads to multiple landing pages — one angle about speed, one about voice matching, one generic. All getting clicks. But by the time a visitor completes signup through Google OAuth or Twitter OAuth, the original URL params are gone. You see a new user in your database. You have no idea which LP or which copy variant sent them.






The fix: cookie before redirect



The solution is straightforward once you see it:




  1. On first page load, write the landing page path + A/B variant to a cookie — before any auth redirect happens

  2. On account creation (server-side), read that cookie back and persist both fields on the user record

  3. The cookie survives OAuth round-trips regardless of which auth method they use




CODE
// middleware.ts — runs on first page load
if (request.nextUrl.pathname.startsWith('/lp/')) {
response.cookies.set('signup_landing_page', request.nextUrl.pathname, { maxAge: 3600 })
response.cookies.set('ab_variant', getVariantFromCookie(request), { maxAge: 3600 })
}









CODE
# users_controller.rb — on account creation
user.signup_landing_page = cookies[:signup_landing_page]
user.ab_variant = cookies[:ab_variant]









Why not just use GA4?



GA4 session attribution and database-level user attribution tell different stories when auth redirects are involved. GA4 may correctly attribute the session to the landing page — but if you want to segment your actual converted users by which LP they came from (to measure LTV, churn rate, or feature adoption by cohort), you need it on the user record.



Now every new signup in XreplyAI carries signup_landing_page and ab_variant. First week of data is already changing where ad spend goes.



About 30 lines of middleware total. Worth the afternoon.






Built for XreplyAI — AI social media tool for solo founders.

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Protect Kubernetes Services with OAuth2 Proxy, Gateway API, Traefik, and Pocket ID
1 Quelle
Request lifecycle: HandlerMapping HandlerAdapter resolvers
1 Quelle
The best n8n fix I found this month was boring: lower your agent concurrency settings before touching the prompt
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to persist landing page attribution across OAuth redirects (30 lines of middleware)

Thematisch verwandte Begriffe: persist, landing, page, attribution · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...