One of Webflow's limitations is that forms can only have a single redirect URL. This creates a challenge when you have forms within CMS templates where each item needs its own unique post-submission destination. For example, you might want to send users to different download links, product pages, or external resources depending on which CMS item's form they submitted.
This step-by-step guide shows you how to implement the BRIX Templates dynamic redirect attribute (brix-dynamic-redirect) to override Webflow's default behavior, allowing each CMS item's form to direct users to a unique URL specified in your CMS data.
This approach eliminates the need for a generic success page and reduces friction in the user experience.
First, you need to add a field to store the unique destination URLs:
Tip: Always use absolute URLs starting with https:// to avoid navigation issues.
Next, mark your form with the special attribute that connects to your CMS redirect URL:
Note: In the form's standard settings, you can leave the Webflow "Redirect URL" blank or set a fallback URL.
Now you'll add the JavaScript that powers the dynamic redirect functionality:
<script>
/*!
* BRIX Templates Dynamic Form Redirect for Webflow
* ----------------------------------------------------------------------------
* Allows forms to redirect to different URLs based on CMS data.
* Just add brix-dynamic-redirect="{Your CMS URL Field}" to your form element.
*
* Version: 1.0.2
* Author: BRIX Templates
*/
(function() {
'use strict';
//--------------------------------------------------------------------------
// Main Initialization
//--------------------------------------------------------------------------
document.addEventListener('DOMContentLoaded', function() {
// Find all forms with our custom attribute
const forms = document.querySelectorAll('[brix-dynamic-redirect]');
forms.forEach(form => {
// Get the CMS redirect URL directly from the attribute
const cmsURL = form.getAttribute('brix-dynamic-redirect');
// Skip if no valid URL is found
if (!cmsURL) return;
// Set both redirect attributes for maximum compatibility
form.setAttribute('redirect', cmsURL);
form.setAttribute('data-redirect', cmsURL);
console.log('BRIX Dynamic Redirect: Form will redirect to ' + cmsURL);
});
});
})();
</script>
The code automatically detects forms with the attribute and sets up the proper redirects using your CMS data. No code modification is needed.
Note: If you're using this functionality across multiple CMS templates, you can add the script to Project Settings > Custom Code > Footer Code instead. This applies the dynamic redirect behavior site-wide without having to add the code to each individual template page.
After setting up the code, it's time to get everything working:
Remember that form redirects only work in published environments, not in the Designer preview.
If your dynamic redirects aren't working properly, check these common problems:
The script intentionally uses both redirect and data-redirect attributes to ensure compatibility with different versions of Webflow's form handling.
By implementing dynamic form redirects with the brix-dynamic-redirect attribute, you can create personalized user experiences that send visitors to the most relevant destination based on CMS context. This simple solution dramatically improves your site's usability by removing the limitation of Webflow's single redirect URL setting.
The approach requires minimal code and works reliably across all Webflow plans. Best of all, once implemented, it continues to work automatically as you add new items to your CMS collection—no need to update the code or create new forms.
Need more advanced form functionality or custom Webflow solutions? Our agency specializes in extending Webflow's capabilities with clean, maintainable code. Contact us to learn how we can help optimize your Webflow project.
Learn 2 simple methods to quickly check if a site is built with Webflow using browser tools or manual inspection with our easy tutorial.
Find out if any website uses Framer with our straightforward guide showing 2 simple methods - using Wappalyzer or inspecting source code.
Learn how to implement cross-page anchor links in Webflow to direct users to specific sections across your site. 5min step-by-step tutorial.