At the top of your index page.
You could add.
if( isset( $_GET['ref'] ) && $_GET['ref'] !== '' )
wp_safe_redirect( '/signup' )
Then, on the sign up page add:
$the_referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
So you can do whatever you want with that, I would add some escaping etc and you’ll prob have to str_replace()
to get the ID solely.
Thanks.