Pass URL parameter to next page upon pressing a CTA button


Would like to ask for help on a situation. I have got the following url parameter appended:

I have a CTA button, which will lead to a form block, where I would like to have a hidden field to capture the phone number above. How a custom code can make it happen?

I tried with the following consulting the Notion AI, but it is not working, anyone has an idea of it? I think this should be quite an interesting topic a lot of users would like to know.

document.addEventListener('DOMContentLoaded', () => {
  const contactUsButton = document.querySelector('.MuiButton-containedPrimary');
  contactUsButton.addEventListener('click', () => {
    const currentUrl = window.location.href;
    console.log('Current URL:', currentUrl);
    const fans = new URLSearchParams('fans');
    console.log('Fans parameter:', fans);
    const redirectUrl = `${fans}`;
    console.log('Redirect URL:', redirectUrl);
    setTimeout(() => {
      window.location.href = redirectUrl;
    }, 2000);

Appreciate kind assistance!

Tks & Bgds