Import and use a variable in additional settings of Contact Form 7 [closed]

if only the domain changes, you could try using relative urls:

document.location="/thank-you";

But if the domain you’re redirecting to is different than the page you’re on, a simple way to fix this problem would be to add a customizer value redirect_domain, and then make it a global variable in footer.php

<script>var RedirectUrl=<?php echo get_theme_mod(redirect_domain);?></script>

then in your on_sent_ok you should be able to use the RedirectUrl variable