
Building a UTM Attribution Engine with Supabase Edge Functions (Open Source)
One of the hardest problems in marketing automation is attribution — knowing which ad drove which payment. I built an open-source UTM attribution engine using Supabase Edge Functions. Here is how it works. The Problem A coach runs Meta ads → visitor lands on landing page → eventually pays on Razorpay. But how do you connect the ad click to the payment? The Solution: 3 Edge Functions 1. track-visitor When someone lands on your page, a JavaScript snippet captures UTM parameters and sends them to a Supabase Edge Function: // Captures utm_source, utm_medium, utm_campaign, utm_content fetch ( TRACK_URL , { method : " POST " , body : JSON . stringify ({ visitor_id : visitorId , utm_source : getCookie ( " utm_source " ), utm_campaign : getCookie ( " utm_campaign " ), page_url : window . location . href }) }); The Edge Function also detects the visitor city using Cloudflare headers — free, no API key needed. 2. razorpay-webhook When a payment is captured, Razorpay sends a webhook. Our Edge Fun
Continue reading on Dev.to Tutorial
Opens in a new tab




