I’m currently working on setting up a multilingual website using Webflow’s localization feature, and I’m wondering if there’s a way to redirect users to a “thank you page” based on their selected language.
At the moment, I’ve noticed that the redirection link is only accessible on the primary language version of the site. Does anyone know if there’s a way to implement custom code to achieve this functionality for all language versions?
If you have any insights or solutions to share, please let me know. Your help would be greatly appreciated!
For anyone in need of the code to make this work, please find it below!
<script>
document.addEventListener("DOMContentLoaded", function () {
// use getElementByClass if you want to target the class of the form instead of the ID
var form = document.getElementById('ID of your form');
if (form) {
// Check the current page URL for language identification. In this example there are two possible languages, Dutch (nl) and English (en)
if (window.location.href.includes("/nl/")) {
// For Dutch language pages
form.setAttribute('action', 'url of dutch landing page');
} else if (window.location.href.includes("/en/")) {
// For English language pages
form.setAttribute('action', 'url of english landing page');
}
}
});
</script>