Dynamic Redirect from Webhook Response
Dynamic Redirect lets your webhook endpoint control where the user goes after submitting your funnel. Instead of always redirecting to the same thank-you page, your server can return a different URL for each lead based on qualification, geography, or any custom logic. This is commonly used for lead routing, A/B testing offer pages, and conditional post-submit experiences.
How It Works
- A visitor submits your funnel.
- LeadCapture sends the lead data to your webhook synchronously (waits for a response).
- Your webhook responds with a JSON body that includes a redirect URL.
- LeadCapture redirects the visitor to that URL.
If no valid redirect URL is returned, the visitor sees your normal thank-you step or follows your standard redirect configuration.
Setting Up Dynamic Redirect
- Open your funnel in the builder and go to Lead Delivery.
- Select the webhook you want to use for dynamic redirect.
- Open Advanced Settings.
- Enable Wait for Response. This is required because LeadCapture needs to capture the webhook response before the user is redirected.
- Set the Response Redirect Field to the JSON field name your endpoint returns the URL in (default:
redirect_url). - Optionally set a Fallback Redirect URL for cases where the webhook does not return a valid redirect.
Webhook Response Format
Your endpoint should return a JSON response with the redirect URL in the configured field. For example, with the default field name redirect_url:
{
"success": true,
"lead_id": "abc123",
"redirect_url": "https://example.com/custom-thank-you"
}
The redirect URL must start with http:// or https:// to be considered valid.
When the Fallback URL Is Used
The fallback redirect URL kicks in when the webhook response does not provide a valid redirect. Specifically:
| Scenario | Result |
|---|---|
| Webhook returns a valid redirect URL | User is redirected to that URL |
Redirect field is null or empty |
Fallback URL is used |
| Redirect field is not a valid URL | Fallback URL is used |
| Redirect field is missing from response | Fallback URL is used |
| Webhook request fails (timeout, network error) | Fallback URL is used |
| No fallback URL configured | Normal thank-you step or step-level redirect applies |
Redirect Priority Order
LeadCapture checks for redirects in this order:
- Webhook Dynamic Redirect (highest priority): A valid URL from the webhook response.
- Webhook Fallback URL: If no valid URL from the response.
- Step-Level Redirect: The redirect URL configured on your thank-you step.
- Default: Display the thank-you step without redirecting.
Example Use Cases
Lead Qualification Routing
Your webhook endpoint evaluates each lead and returns a different destination:
// High-value lead
{ "redirect_url": "https://example.com/premium-offer" }
// Standard lead
{ "redirect_url": "https://example.com/standard-offer" }
// Unqualified lead (no redirect, show default thank-you)
{ "success": true }
Geographic Routing
Route leads to region-specific pages based on the state or zip code:
// California leads
{ "redirect_url": "https://west.example.com/thank-you" }
// New York leads
{ "redirect_url": "https://east.example.com/thank-you" }
Performance Note
When Wait for Response is enabled, the lead submission waits for your webhook to respond before the user sees the next step. This adds a slight delay equal to your endpoint's response time. For this reason, only enable this setting on webhooks that need to return data to the client. All other webhooks should use the default asynchronous delivery for best performance.
Pro Tips
- You can mix sync and async webhooks on the same funnel. Only the webhook with "Wait for Response" enabled is delivered synchronously; all others are delivered in the background.
- If multiple sync webhooks return redirect URLs, the first one wins.
- Dynamic redirect works in both hosted funnel pages and embedded funnels.
- Always configure a fallback URL as a safety net in case your endpoint is slow or returns unexpected data.
- There is a brief delay (about half a second) before the redirect so the visitor can see the submission confirmation.