// parse the current page search params const pageSearchParams = new URLSearchParams(window.location.search) // find the button on the page const button = document.querySelector('#trackme') // parse the url from the button const href = new URL(button.href) // parse the search params from the url const buttonSearchParams = new URLSearchParams(href.search) // set the search param you want from the page buttonSearchParams.set("advisor", pageSearchParams.get("advisor")) // update the search for the url href.search = buttonSearchParams.toString() // update the button url button.href = href.toString()