{"slug":"supabase-quiz-funnel-backend","title":"Supabase Backend for Quiz Funnel Lead Capture","tags":["supabase","funnel","backend","lead-capture","ghl"],"agent_summary":"Architecture for using Supabase as a server-side backend for quiz funnel lead capture, with per-client data isolation, magic link onboarding, and GHL integration.","trigger_phrases":["supabase funnel backend","quiz funnel database setup","server side lead capture","supabase ghl integration","custom funnel backend architecture","per client data isolation funnel"],"runnable":false,"markdown":"## Supabase Backend for Quiz Funnel Lead Capture\n\n### Architecture\n- Supabase headers/columns capture quiz answers **live** as the user progresses (server-side)\n- Data communicates with database on the backend in real-time\n- Per-client data isolation\n- Once lead submits, all data gets **pushed in one go** to GHL via API\n\n### How It Works\n1. User starts quiz funnel\n2. Each step's answer is captured server-side to Supabase (no data loss if they abandon)\n3. On final submit, complete lead data is pushed to GHL sub-account\n4. Contact is created/upserted in GHL with all quiz fields as custom fields\n\n### Custom Fields vs Notes\n- **Don't** jam quiz answers into a note field\n- **Do** create custom fields per niche for each quiz question\n- Service type → Single option dropdown (e.g., maintenance, design, hardscaping, irrigation)\n- Other fields → Text fields\n- Use GHL MCP to create custom fields on the sub-account programmatically\n\n### Magic Link Onboarding\n- Onboarding form uses magic links\n- System already knows who the customer is (connected to GHL contact)\n- Data populates as they fill it out — no data loss\n\n### Security\n- Location ID and private integration token must NOT be leaked client-side\n- Verify server-side handling of API credentials\n- Meta pixel can be added to the funnel pages for ad tracking\n\n### GHL Integration\n- Connect via location ID + private integration token\n- Upserts contacts (creates or updates existing)\n- Custom fields capture return field IDs for mapping\n- Audit log shows create/update events for verification\n","html":"<h2>Supabase Backend for Quiz Funnel Lead Capture</h2>\n<h3>Architecture</h3>\n<ul>\n<li>Supabase headers/columns capture quiz answers <strong>live</strong> as the user progresses (server-side)</li>\n<li>Data communicates with database on the backend in real-time</li>\n<li>Per-client data isolation</li>\n<li>Once lead submits, all data gets <strong>pushed in one go</strong> to GHL via API</li>\n</ul>\n<h3>How It Works</h3>\n<ol>\n<li>User starts quiz funnel</li>\n<li>Each step's answer is captured server-side to Supabase (no data loss if they abandon)</li>\n<li>On final submit, complete lead data is pushed to GHL sub-account</li>\n<li>Contact is created/upserted in GHL with all quiz fields as custom fields</li>\n</ol>\n<h3>Custom Fields vs Notes</h3>\n<ul>\n<li><strong>Don't</strong> jam quiz answers into a note field</li>\n<li><strong>Do</strong> create custom fields per niche for each quiz question</li>\n<li>Service type → Single option dropdown (e.g., maintenance, design, hardscaping, irrigation)</li>\n<li>Other fields → Text fields</li>\n<li>Use GHL MCP to create custom fields on the sub-account programmatically</li>\n</ul>\n<h3>Magic Link Onboarding</h3>\n<ul>\n<li>Onboarding form uses magic links</li>\n<li>System already knows who the customer is (connected to GHL contact)</li>\n<li>Data populates as they fill it out — no data loss</li>\n</ul>\n<h3>Security</h3>\n<ul>\n<li>Location ID and private integration token must NOT be leaked client-side</li>\n<li>Verify server-side handling of API credentials</li>\n<li>Meta pixel can be added to the funnel pages for ad tracking</li>\n</ul>\n<h3>GHL Integration</h3>\n<ul>\n<li>Connect via location ID + private integration token</li>\n<li>Upserts contacts (creates or updates existing)</li>\n<li>Custom fields capture return field IDs for mapping</li>\n<li>Audit log shows create/update events for verification</li>\n</ul>\n"}