Get data from one page to another using form submission

In this situation I would use sessionStorage.

On your page with the pop-up form, capture the submit event for the form, and save the URL to sessionStorage.

On your thank you page, you can retrieve it and apply it to the button.